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!

Dynamic sql in cursor or if stmt or for loop

709382Jul 30 2009 — edited Jul 30 2009
Hi

I am not able to use dynamic sql in cursors or if statements or for loops.Is there any way for this.
For example

create procedure test_1 as
v_username varchar(40);
v_sql_ac varchar2(50) ;
begin
v_sql_ac := 'select * from dbaoper.t_system_users';
v_username := 'TEST' ;
if v_username not in (execute immediate v_sql_ac) then
dbms_output.put_line (' HI' );
else
dbms_output.put_line ('Bye');
end if;
end;
/


LINE/COL ERROR
-------- -----------------------------------------------------------------
7/31 PLS-00103: Encountered the symbol "IMMEDIATE" when expecting one
of the following:
. ( ) , * @ % & | = - + < / > at in is mod remainder not
range rem => .. <an exponent (**)> <> or != or ~= >= <= <>
and or like LIKE2_ LIKE4_ LIKEC_ between || multiset member
SUBMULTISET_
The symbol ". was inserted before "IMMEDIATE" to continue.



Thanks in Advance


PRamod
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 27 2009
Added on Jul 30 2009
4 comments
594 views