Skip to Main Content

Oracle Database Discussions

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!

Dynamic SQL select from unknown table until runtime

275123Jun 6 2005 — edited Jun 6 2005
I need to do a select from a table that is unknown until runtime. Is there any good examples of this. The Store Procedure will take in the table name and return a row.

I am not using inline SQL because there is a lot more complexity involved . What I need to do is understand how to reference this unknown table.


Here is an example of what I have written so far.

PACKAGE pk_LoadNativeDataItems IS

PROCEDURE version;

TYPE RowDataCur IS REF CURSOR;

PROCEDURE pr_LoadNativeDataItems(p_flag IN NUMBER
p_how_many_rows_to_fetch IN NUMBER,
p_row_data OUT RowDataCur);


PROCEDURE pr_LoadNativeDataItems(p_flag IN NUMBER
p_how_many_rows_to_fetch IN NUMBER,
p_table_name IN VARCHAR,
p_row_data OUT RowDataCur) IS


BEGIN
OPEN p_row_data FOR
SELECT * from ||p_table_name||;
END pr_LoadNativeDataItems;

END pk_LoadNativeDataItems;

Thanks for any help

Tony

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 4 2005
Added on Jun 6 2005
2 comments
398 views