Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> how do you call procedures dynamically
I am looking for a way to call a procedure dynamically (ie, not knowing the name of the procedure at compile time). I have tried quite a few methods but without any luck, I believe that the DBMS_SQL package should allow me to achieve my goal, but I am stuffed if i know how to get it to work.
My first attempt went along the lines of
procedure callIt is
myVariable varchar2(1000) := 'callThisProcedure';
begin
myVariable; -- a vein attempt to run the procedure
"callThisProcedure"
end;
Below is my latest attempt to get this thing working. Any suggestions?
procedure callIt is
handle1 integer; alteredRows integer; begin handle1 := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE (handle1, 'select :proc from dual', DBMS_SQL.V7); DBMS_SQL.BIND_VARIABLE(handle1, ':proc', 'theProcedureIWantToCall); alteredRows := DBMS_SQL.EXECUTE(handle1); DBMS_SQL.CLOSE_CURSOR(handle1); exception when others then DBMS_SQL.CLOSE_CURSOR(handle1);end;
Vice President Work: 203-961-6140 IPD, Operations and Technology Fax: 203-961-6163 Emerging Technologies Group Cell: 100 First Stamford Place Email: simon.spencer_at_citicorp.com7th Floor, Stamford CT.