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!

Dynamically building USING Caluse

user458361Aug 11 2011 — edited Aug 11 2011
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;
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 8 2011
Added on Aug 11 2011
3 comments
107 views