Calling a Stored Procedure Within a Stored Procedure

Call one stored procedure to another stored procedure in DB2

I solved this problem,
So solution is like If we want to execute proc using sql command then syntex is like below,

call Proc2('My Name');

We can use this same approach inside our proc also.
For that we have to follow some steps. Lets say that our above sql call is statement that we want to execute. we are going to convert that statement into String and pass necessary parameter by concating variable values. Then execute statement.

CREATE OR REPLACE PROCEDURE Proc1()
IS
Declare myName in varchar;
-- stmt variable is to execute our proc
STMT VARCHAR(4000);
BEGIN
Select fname into myName from student where fname='x'; // is returning unique value
-- this is our logic
STMT :='call Proc2('||myName||')';
EXECUTE IMMEDIATE STMT;
END;

Calling one stored procedure within another stored procedure using variables from first stored procedure

I'm executing procedures inside other procedures like this:

DECLARE @childResult int, @loaErrorCode int, @loaErrorMessage varchar(255) 
EXEC @childResult = [dbo].[proc_sub_getSomething] @schemes_id = @foo_schemes_i, @errorCode = @loaErrorCode OUTPUT , @errorMessage = @loaErrorMessage OUTPUT

Should it still not work you should edit your question to show your exact code.

Calling a Stored Procedure in a Stored Procedure in MySQL

CREATE PROCEDURE innerproc(OUT param1 INT)
BEGIN
insert into sometable;
SELECT LAST_INSERT_ID() into param1 ;
END
-----------------------------------
CREATE PROCEDURE outerproc()
BEGIN
CALL innerproc(@a);
// @a gives you the result of innerproc
SELECT @a INTO variableinouterproc FROM dual;
END

OUT parameters should help you in getting the values back to the calling procedure.Based on that the solution must be something like this.



Related Topics



Leave a reply



Submit