Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How can i retrieve all values from database column separated by comma in oracle.
Posted

Hello Shan,

For Oracle 11g R2 you can try following syntax
SQL
SELECT LISTAGG(COLUMN_NAME, ', ') WITHIN GROUP (ORDER BY COLUMN_NAME)
FROM TABLE

More details can be found here[^].

Regards,
 
Share this answer
 
Comments
Thanks7872 16-Oct-13 4:38am    
Repost.

http://www.codeproject.com/Questions/669361/data-table-comma-separated-values
Prasad Khandekar 16-Oct-13 4:44am    
It looks bit different, it talks about datatable and probably requires a different solution.
Thanks7872 16-Oct-13 4:46am    
What? looks different? How? Just visually? He explained in detail there and shortened here.
Prasad Khandekar 16-Oct-13 5:01am    
Hello Rohan,

He is looking a C# solution in that thread and has also given the answer in the same. However in this question he is asking whether it can be done via a database query.

(I really liked the quote you have used on your profile)

Regards,
Thanks7872 16-Oct-13 5:07am    
Oh..Thanks. :-)
XML
Get list all colums names in datatable from oracle using below query

SELECT column_name
 FROM user_tab_cols
 WHERE table_name=UPPER('APP_COUNTRY_MASTER')

In c# you can put commas between names
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900