How to retrieve column names in a query in a case sensitive way
451392Nov 7 2008 — edited Nov 7 2008Given a query, I want to extract all the column names/aliases in the query in a case-sensitive way.
When I use dbms_sql.describe_columns() or java.sql.ResultSetMetaData classes getColumnName() or getColumnLabel()
it returns the columns name ONLY in Upper case.
My application needs to extract the column names in the same case as it appears in the query string.
Is there any API to get this without parsing the SQL query string?
Thanks
PS: The dbms_sql.describe_columns() returns the column name in upper case.
declare
IS
l_column_recs DBMS_SQL.DESC_TAB;
l_cur NUMBER;
l_column_count NUMBER;
BEGIN
l_cur := dbms_sql.open_cursor;
dbms_sql.parse(l_cur, 'select target_type from targets', dbms_sql.NATIVE);
dbms_sql.describe_columns(l_cur, l_column_count, l_column_recs);
FOR i IN l_column_recs.FIRST..l_column_recs.LAST
LOOP
dbms_output.put_line(l_column_recs(i).col_name);
end loop;
end;
/