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 Bind Variables in Execute immediate

MouleeswarSep 4 2018 — edited Nov 1 2018

Hello,

Trying to execute a query with dynamic bind variables like as follows:

I have two set of tables say TAB_QUERY and TAB_PARAMETERS.

TAB_QUERY has a column query_text and will be used to save queries

i.e, SELECT * FROM EMP WHERE EMPNO=:1 and DEPTNO=:1 and ENAME=:3

TAB_PARAMETERS store the passing parameters list in multiple rows for the corresponding query.

1234

10

'SCOTT'

so, the plan is to run the query with the list of parameters inserted in the TAB_PARAMETERS table.

declare

cursor c is

select query_text from TAB_QUERY;

cursor c_param (InParam IN NUMBER) is

select * from TAB_PARAMETERS where query_id = InParam ;

begin

For Indx in C LOOP

FOR Jndx IN c_param(Indx.Query_id)

Execute immediate Jndx.query_text using ????

END LOOP;

END LOOP;

end;

Is there any way to make this program run?

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 3 2018
Added on Sep 4 2018
19 comments
2,365 views