Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to create a Type Object with Dynamic select query columns in a Function

834872Jan 27 2011 — edited Jan 31 2011
Hi Every One,

I'm trying to figure out how to write a piplined function that executes a dynamic select query and construct a Type Object in order to assigned it to the pipe row.

I have tried by

SELECT a.DB_QUERY INTO actual_query FROM mytable a WHERE a.country_code = 'US';

c :=DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c,actual_query,DBMS_SQL.NATIVE);

l_status := DBMS_SQL.EXECUTE(c);

DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);

FOR j in 1..col_cnt LOOP
DBMS_SQL.DEFINE_COLUMN(c,j,v_val,2000);
END LOOP;

FOR j in 1..col_cnt LOOP
DBMS_SQL.COLUMN_VALUE(c,j,v_val);
END LOOP;


But got stuck, how to iterate the values and assign to a Type Object from the cursor. Can any one guide me how to do the process.

Thanks,
mallikj2
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 28 2011
Added on Jan 27 2011
7 comments
498 views