Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic SQL - Cursor How To

Status
Not open for further replies.

wellster34

Programmer
Sep 4, 2001
113
CA
Hi,

I need to be able to create a cursor for a select statement so that I can process each record one by one.

Here are the catches:
* The Select statement is not hardcoded since it is dynamic. So, I do not know the tables or columns to be used.

Is there a way?

Thanks
[dazed]
 
You may use REF CURSOR but knowing the structure of result set is a must to be able to fetch cursor to a variable for further processing.



Regards, Dima
 
Ref cursors are infinately preferrable to pure dynamic SQL, but if you do not know the structure you will need to use 'method 4' with the DBMS_SQL package. This will include a DBMS_SQL.PREPARE statement to identify and query an unknown number of columns. You will need to check your Oracle documentation for a more thorough explanation of this method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top