|
Re: Retrieving Multiple Rows of Single Column as a String concatenated with comma [message #36437 is a reply to message #36435] |
Tue, 27 November 2001 22:13  |
Rob Baillie
Messages: 33 Registered: November 2001
|
Member |
|
|
Well, here's a starting point for you...
DECLARE
--
lc_return_string VARCHAR2(2000);
--
CURSOR cur_string IS
SELECT some_string
FROM some_table
ORDER BY some_field;
--
BEGIN
--
DBMS_OUTPUT.ENABLE;
--
FOR string_rec IN cur_string LOOP
IF lc_return_string IS NOT NULL THEN
lc_return_string := lc_return_string || ',' || string_rec.some_string;
ELSE
lc_return_string := string_rec.some_string;
END IF;
END LOOP;
--
DBMS_OUTPUT.PUT_LINE( lc_return_string );
--
END;
/
Though if anyone knows how to do it in a single select statement I'd be VERY VERY impressed...
----------------------------------------------------------------------
|
|
|