Thanks for the question.
Asked: June 19, 2017 - 11:29 am UTC
Last updated: June 20, 2017 - 4:24 am UTC
Version: 11
Viewed 1000+ times
SQL> create or replace 2 procedure p(col varchar2, val varchar2) is 3 rc sys_refcursor; 4 inj_test varchar2(255); 5 6 type elist is table of scott.emp%rowtype index by pls_integer; 7 r elist; 8 begin 9 10 select sys.dbms_assert.simple_sql_name(col) into inj_test from dual; 11 open rc for 'select * from scott.emp where '||col||' = :1' using val; 12 13 fetch rc bulk collect into r; 14 close rc; 15 16 for i in 1 .. r.count loop 17 dbms_output.put_line(r(i).empno||','||r(i).ename); 18 end loop; 19 end; 20 / Procedure created. SQL> SQL> set serverout on SQL> exec p('DEPTNO',10); 7782,CLARK 7839,KING 7934,MILLER
A reader, June 20, 2017 - 6:07 am UTC
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library