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!

Avoid use of cursor?

user12945439Oct 21 2010 — edited Oct 21 2010
Hi all,

I've a procedure that should run:

SELECT DATA
INTO MYDATA
FROM SCHEMA.TABLE ;

Schema should be result of a concatenated string SCHEMA+VAR (where var is the first parameter of my procedure). To do this I have to use a

MYQUERY := 'SELECT DATA INTO MYDATA FROM SCHEMA'||VAR||'.TABLE ;'
dbms_output.put_line(MYQUERY);
begin
execute immediate MYQUERY
end


Execute immediate is not compatible with a construct similar to SELECT SOMETHING INTO ANOTHERTHING and to resolve this I should use a cursor.
Is not clear if I can avoid the use of a cursor to do this simple thing or I have to create a cursor for each of my statement in procedure like this one (7 statements) and so create,manage,destroy 7 cursors.

Any hints?

thanks
Ste
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 18 2010
Added on Oct 21 2010
6 comments
587 views