Hello,
I want to call a Stored Procedure from another Stored Procedure, dynamically. I have pasted a code snippet below:
Eg: I have few Stored Procs as below:
CREATE PROCEDURE CAL_DISCOUNT(IN value1 INTEGER, IN disc INTEGER) AS
BEGIN
...
..
.
END;
CREATE PROCEDURE CAL_DISCOUNT_V1(IN value1 INTEGER, IN disc INTEGER) AS
BEGIN
...
..
.
END;
Now I have my main Stored Proc which takes the name of the procedure to call as an input:
CREATE PROCEDURE MY_PROC( IN dyn_proc_name nvarchar(50) AS
BEGIN
...
CALL dyn_proc_name (:var1, :var2);
..
...
END;
I want to now call the main proc as below:
CALL MY_PROC('CAL_DISCOUNT');
This should call CAL_DISCOUNT and pass 2 values (defined within the PROCEDURE MY_PROC) dynamically. I was able to call a Procedure using EXECUTE IMMEDIATE when the procedure did not take any input. But when I call a procedure and pass an input it fails. I tried 'USING' syntax with EXECUTE IMMEDITATE, but it was throwing error.
Any pointers?
Regards,