You have 2 MySQL stored procedures, both that select return codes at the end. You need to call 1 stored procedure within another, and get its return code. Is this possible?
Proc1:
CREATE PROCEDURE (IN...)
BEGIN
DECLARE ret_code
...UPDATE SOMETHING....
SELECT ret_code as return_code from dual;
END
Proc2:
CREATE PROCEDURE (IN...)
BEGIN
DECLARE returnVal
if(conditional true)
..Update something else..
Set returnVal = x;
else
call proc1(var1,...)
Set returnVal = (ret_code obtained from proc1)
end if
select returnVal;
END
When calling proc1 within proc2, how can I get that ret_code that’s selected at the end of proc1 within proc2?
You should either use
CREATE FUNCTIONinstead ofCREATE PROCEDURE:or else specify an
OUTparameter to the procedure, and use that: