no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | blog:commalistofcolumns [2009/11/27 17:53] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Table column list ====== | ||
+ | How to get a CSV list of columns for a table? | ||
+ | |||
+ | <code oracle8> | ||
+ | /** Supplied with a table name return a comma separated list of its columns in ascending order. | ||
+ | */ | ||
+ | FUNCTION getColumnList (fromuser VARCHAR2, ptablename VARCHAR2) return VARCHAR2 IS | ||
+ | columnArray dbms_utility.uncl_array; | ||
+ | csvLen binary_integer; | ||
+ | csvList varchar2(4000); | ||
+ | BEGIN | ||
+ | select column_name | ||
+ | bulk collect into columnArray | ||
+ | from all_tab_cols | ||
+ | where table_name = ptablename | ||
+ | and owner = fromuser | ||
+ | and hidden_column = ' | ||
+ | order by column_name; | ||
+ | |||
+ | dbms_utility.table_to_comma(columnArray, | ||
+ | |||
+ | return csvList; | ||
+ | END; | ||
+ | </ | ||
+ | {{tag> |