I am trying to show all the names of the columns in a table, separated by a comma in a single row and then save them in a variable.
Which is the best way?
I have somethig like this:
SELECT tab.column_name || decode(lead(tab.column_name,1) over (order by tab.column_id),null,'',',')
FROM
all_tab_columns tab,
all_constraints pk,
all_cons_columns pk_det
WHERE
tab.table_name = pk.table_name (+)
and pk.table_name = pk_det.table_name (+)
and tab.owner = pk.owner (+)
and pk.owner = pk_det.owner (+)
and pk.constraint_name = pk_det.constraint_name (+)
and tab.column_name = pk_det.column_name (+)
and tab.data_type not like '%LOB%'
and tab.owner = :OWNER_SOURCE
and tab.table_name = :TABLE_NAME_SOURCE
And the result is this:
ID,
_LOCALE,
LABEL,
OBSERVATIONS
But... I need this way:
ID,_LOCALE,LABEL,OBSERVATIONS
Thanks in advance.