select userid from users where usergrp='1'This query retrieves around 10 records. I have a task to concatenate the values separated with ','. I would like to know if Oracle has any function that could do that.
create or replace function concat( cur sys_refcursor )return varchar2 is retval varchar2(32767); hold varchar2(80);begin loop fetch cur into tmp; exit when cur%notfound; ret := ret || ',' || hold; end loop; return retval;end;/ select distinct substr (concat( cursor( select userid from users outer where e.usergrp = outer.usergrp ) ),1,40) useridsfrom users e;
Dig Deeper on Oracle and SQL
Related Q&A from Don Burleson
What is table partitioning and what are its advantages and disadvantages? Also, what is bulk collection? What are hints? Continue Reading
In Oracle 9i, is there a way to identify the specific row being locked in a particular table? I have seen much code that identifies the object being ... Continue Reading
I am having a problem viewing the queries in v$sqlarea. I have a procedure (p1) with lots of insert, select, update and delete statements. I am ... Continue Reading