troubleshooting Question

Get Column Names From SELECT statement

Avatar of ryeandi
ryeandi asked on
Oracle Database
3 Comments1 Solution1298 ViewsLast Modified:
I have a PL/SQL procedure that is passed a valid SELECT statement as a VARCHAR2 parameter.  I would like to be able to get the column names from this statement.  Below is a simple example of that gets to the root of what i'd like to do.

CREATE OR REPLACE PROCEDURE proc_print_col_names (p_select               IN            VARCHAR2)
v_column_name                       VARCHAR2(255)                             := NULL;
v_column_name := ????? -- Get first column from p_select
WHILE v_column_name IS NOT NULL LOOP
  DBMS_OUTPUT.PUT_LINE('Column Name = ' || v_column_name);
  v_column_name := ????? -- Get next column from p_select  

Please help!

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros