I have a query in Oracle that I am trying to have the parameters used in the retrieval to show up as part of the select.

Essentially I have an array that is passed in through PowerBuilder and several other arguments. Its a string array that I need to have returned back as part of the results.

The Procedure is pasted below, though its rather long and not mine (I am just coming onto this project).

The :BU parameter has to be returned to the results from the Select so that it may be displayed in the datawindow as a string.

ie: The BU array Parameter returned as a string in the select as BU[1] + ', ' + BU[2] ', ' + BU[3] ... etc.

Many thanks in advance for this and the surplus of questions and advice that I will be needing in the near future.

Gooddawggy

========================================================
select distinct csv1.element_value as acct_sel,
case when unit_list.sel_rollup_fg=1 then pcu.description else unit_list.sel_rollup end as sel_rollup,
unit_list.sel_base_desc as sel_base, unit_list.lev1_rollup, unit_list.lev1_base_desc as lev1_base,
unit_list.lev2_rollup, unit_list.lev2_base_desc as lev2_base, unit_list.lev3_rollup,
sum(amts.mo_act) as mo_act, sum(amts.mo_bud) as mo_bud, sum(amts.mo_act) - sum(amts.mo_bud) as mo_var,
sum(amts.yr_act) as yr_act, sum(amts.yr_bud) as yr_bud, sum(amts.yr_act) - sum(amts.yr_bud) as yr_var,
to_date(:MONTH, 'yyyymm') as month_year
from pnw_cr_unit pcu, cr_structure_values csv, cr_structure_values csv1,
(
SELECT ccr.charge_unit unit, ccr.account acct, ccr.resource_category rc,
nvl(sum(ccr.amount), 0) mo_act, 0 yr_act, 0 mo_bud, 0 yr_bud
FROM cr_cost_repository ccr
where ccr.month_number = :MONTH
and ccr.entity in (:BU)
GROUP BY ccr.charge_unit, ccr.account, ccr.resource_category

union

SELECT ccr.charge_unit unit, ccr.account acct, ccr.resource_category rc,
0 mo_act, nvl(sum(ccr.amount), 0) yr_act, 0 mo_bud, 0 yr_bud
FROM cr_cost_repository ccr
WHERE ccr.month_number between to_number(to_char(to_date(:MONTH, 'yyyymm'), 'yyyy') || '01') and :MONTH
and ccr.entity in (:BU)
GROUP BY ccr.charge_unit, ccr.account, ccr.resource_category

union

SELECT distinct cbd.charge_unit unit, cbd.account acct, cbd.resource_category rc,
0 mo_act, 0 yr_act, nvl(sum(cbd.amount), 0) mo_bud, 0 yr_bud
FROM cr_budget_data cbd
WHERE cbd.month_number = :MONTH
and cbd.entity in (:BU)
GROUP BY cbd.charge_unit, cbd.account, cbd.resource_category
union

SELECT distinct cbd.charge_unit unit, cbd.account acct, cbd.resource_category rc,
0 mo_act, 0 yr_act, 0 mo_bud, nvl(sum(cbd.amount), 0) yr_bud
FROM cr_budget_data cbd
WHERE cbd.month_number between to_number(to_char(to_date(:MONTH, 'yyyymm'), 'yyyy') || '01') and :MONTH
and cbd.entity in (:BU)
GROUP BY cbd.charge_unit, cbd.account, cbd.resource_category
) amts,
......