Executing a procedure from form based on variable name [message #501878] |
Fri, 01 April 2011 03:25 |
sethumurugan
Messages: 61 Registered: June 2010 Location: Chennai
|
Member |
|
|
Hi,
I need to execute a procedure based on a value in a form. So the procedure name will be changing for value selected in a list.
I need to know a method where i could store the procedure name in a table and when ever i select a value from the list, the respective procedure needs to be executed.
Request you to help me in these points
Sethu
|
|
|
Re: Executing a procedure from form based on variable name [message #501886 is a reply to message #501878] |
Fri, 01 April 2011 04:31 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
If you really need to do that, perhaps you'd rather do that in a following manner:- create a table that will contain procedures' names
- create a "menu" stored procedure that will call all those procedures. You'd use EXECUTE IMMEDIATE to do that.
- a form should call the "menu" stored procedure
Here's a simplified example of a "menu" procedure (that belongs to a package) (I hope I didn't delete too much of it!).
Procedures' names are stored in KONTROLA table (column PROCEDURA). They accept one parameter whose name is PAR_VRIJEDNOST, which is retrieved from a cursor (column PARAMETRI.VRIJEDNOST).
-- The "menu" stored procedure
procedure kontrola is
l_exec varchar2(500);
begin
for cur_k in (select p.vrijednost,
s.procedura
from parametri p,
kontrola s
where s.kontrola_id = p.kontrola_id
)
loop
l_exec := 'begin pkg.' || cur_k.procedura ||'(par_vrijednost => ' || cur_k.vrijednost ||
');' ||
' end;';
execute immediate (l_exec);
end loop;
end kontrola;
|
|
|