Code Cave

Things brought out of the darkness

Thursday, March 20, 2008

An alternate way to get a comma separated list of values from a table

QUERY SAMPLE


with data
as
(
select myvalues, row_number() over (order by myvalues) rn, count(*) over () cnt
from
(
select VC_EMAILADDESS myvalues from TBL_EMAIL_ADDRESSES
)
)

select ltrim(sys_connect_by_path(myvalues, ','),',') catvalues
INTO p_vc_to
from data
where rn = cnt
start with rn = 1
connect by prior rn = rn-1;





RESULT

P_VC_TO = item1,item2


SOURCE

http://www.quest-pipelines.com/pipelines/plsql/tips.htm#JULY

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home