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
Compare Comma Separated Values in SQL
As400 SQL Query with Parameter
Aggregate Strings in Azure SQL Data Warehouse
Trimmining a Column with Bad Data
Get Sundays for a Given Month Date in a Function SQL
Fixing Holes/Gaps in Numbers Generated by Postgres Sequence
How to Create Sequence Using Starting Value from Query
Update Oracle Table with Values from CSV File
How to Get Rows Having Sum Equal to Given Value
Find the Byte Size of a Row in Postgresql
How to Force Nolock Hint for SQL Server Logins
Query on Datetime Fields with Milliseconds Gives Wrong Result in SQL Server
SQL Server - Give a Login Permission for Read Access to All Existing and Future Databases