Dynamic Procedure Calling [message #190972] |
Sun, 03 September 2006 12:26 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
dcaptain
Messages: 4 Registered: September 2006 Location: Philippines
|
Junior Member |
![csev14%40yahoo.com](/forum/theme/orafaq/images/yahoo.png)
|
|
Hi,
We will implement calling of procedure based on the value fetch by the database. Is it possible?
sample code..declare
v_proc varchar2(30);
begin
v_proc := :control.proc;
if v_proc = 'SP1' then
SP1;
elsif v_proc = 'SP2' then
SP2;
end if;
end;
instead..
declare
v_proc varchar2(30);
begin
v_proc := :control.proc;
call name_in(v_proc); -- assuming dynamic call
end;
Any solution like this would greatly appreciated instead of repeating the code depends on how many stored proc to be called.
Many Thanks,
Cap
[Updated on: Mon, 11 September 2006 02:39] by Moderator Report message to a moderator
|
|
|
Re: Dynamic Procedure Calling [message #191336 is a reply to message #190972] |
Tue, 05 September 2006 15:12 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
RJ.Zijlstra
Messages: 104 Registered: December 2005 Location: Netherlands - IJmuiden
|
Senior Member |
|
|
Hi Captain,
I don't think it's possible:
At compile time, how can the compiler know the name of the procedure and therefore is able to decide if this a correct name, if you have rights to execute it, etc etc.
But I might be wrong!
Regards,
Rob Zijlstra
|
|
|
|
Re: Dynamic Procedure Calling [message #191763 is a reply to message #190972] |
Fri, 08 September 2006 01:26 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
sandeepk7
Messages: 137 Registered: September 2006
|
Senior Member |
![sandeep_kushwaha](/forum/theme/orafaq/images/yahoo.png)
|
|
Create a database procedure like
CREATE OR REPLACE PROCEDURE exec_Dynamic_Proc_sp
(Proc_Name IN VARCHAR2)
IS
BEGIN
IF Proc_Name IS NOT NULL THEN
EXECUTE IMMEDIATE ('Exec '||Proc_Name);
END IF;
EXCEPTION
/* write exceptions according to your nead. Like is passed procedure
does not exists or user do not have access to execute that procedure.
you can also check the existence of procedure before execute
immediate by checking in object table.*/
WHEN OTHERS
null;
END; then call this procedure in your form like.begin
Exec_Dynamic_proc_sp(:control.proc);
end;
Sandy
[Updated on: Mon, 11 September 2006 02:44] by Moderator Report message to a moderator
|
|
|
Re: Dynamic Procedure Calling [message #191767 is a reply to message #191763] |
Fri, 08 September 2006 01:44 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
dcaptain
Messages: 4 Registered: September 2006 Location: Philippines
|
Junior Member |
![csev14%40yahoo.com](/forum/theme/orafaq/images/yahoo.png)
|
|
Thanks for the reply Sandy..
What if it's not a Backend Procedure..
It's a PROGRAM UNIT..
you want to dynamically called a program unit using Developer Forms...
sample
Program units name as follows;
SP_1
SP_2
SP_3
table tbl_dyn_sp
Code Description
SP_1 Stored procedure Test1
SP_2 Stored procedure Test1
SP_3 Stored procedure Test1
-- code proper --
declare
v_code varchar2(30);
cursor c1 (p1 varchar2) is
select code
from tbl_dyn_sp
where code = p1;
begin
open c1(<variable>);
fetch c1 into v_code;
close c1;
-- here is my question --
-- how would I call the Program unit
-- depends on the variable passed?
call v_code; -- any other way to invoke the Program units?
--
end; Thanks and God Bless! ![Smile](images/smiley_icons/icon_smile.gif)
Cap
[Updated on: Mon, 11 September 2006 02:46] by Moderator Report message to a moderator
|
|
|
Re: Dynamic Procedure Calling [message #192130 is a reply to message #191767] |
Mon, 11 September 2006 02:48 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/67467.jpg) |
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
I would suggest that you don't use program units to do 'work'. It is inefficient in terms of doing database processing. Program units and program libraries should be used for doing 'forms' work, not database work.
David
|
|
|