Link to home
Create AccountLog in
Avatar of jl66
jl66Flag for United States of America

asked on

pl/sql variable replace issue

declare

-- should pass in the diff. schemas. How to do that???

v1 varchar2(100) := "'SYSTEM','SCOTT'";

CURSOR tbl_cur IS
select table_name from dba_tables where owner in (v1);

Begin
for i in tbl_cur
loop
 dbms_output.put_line(i);
-- expecting to print all table names in scott and system
end loop;

end;
/

Get a lot of errors. For example,
...
PLS-00201: identifier ''SYSTEM','SCOTT'' must be declared
...

Questions:
1) how to pass in the variables with ','?
2) how to replace the variables in the sql statement?
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of Sean Stuber
Sean Stuber

dynamic sql carries its own overhead.  Like instr it can also work, but your dba will hate you for using string concatenation of literals instead of using bind variables
Avatar of jl66

ASKER

Excellent!!