Dynamically building USING Caluse
Hi,
I have a requirement to convert all literals used in a SQL to bind variable, But this SQL is getting generated dynamically .
I will get to know WHERE clause and parameters values only at the run time.
Trying to implement some solution by reading the SQL string and dynamically build the USING clause ,
Tried below script but getting exception, any help is appreciated.
Regards
Ben
Declare
V_sql varchar2(200);
V_sql2 varchar2(200);
E_id varchar2(15);
V_rec_type number(2);
Begin
E_id := 'M100';
V_rec_type := 2;
V_sql := 'insert into EMP_TESTselect * from EMPLOYEE where EMP_ID= :E_id and record_type =:V_rec_type';
V_sql2 :=' E_id, V_rec_type'; -- Hard coded for time being , Will be dynamically generated by reading the SQL.
Open cursor for V_sql using V_sql2';
Loop
--
--
End loop;
End;
/