CREATE PROCEDURE DB2DBA.proc_name
(IN in_var INTEGER,
:
OUT SQL_CODE INTEGER,
OUT SQL_STATE CHARACTER(5)
)
SPECIFIC DB2DBA.proc_name
DYNAMIC RESULT SETS 1
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
MODIFIES SQL DATA
begin P1
declare SQLSTATE CHAR(5) DEFAULT '00000';
declare SQLCODE INT DEFAULT 0;
:
:
declare continue handler for sqlexception, sqlwarning, not found
begin
select sqlcode, sqlstate into v_sql_code, v_sql_state from sysibm.sysdummy1;
end;
:
:
set SQL_CODE = v_sql_code;
set SQL_STATE = v_sql_state;
end P1
put the condition handler in above for your called procedure. then pass back the sqlcode, sqlstate or both to trap the error code in the called procedure.
you may only want the sqlexception handler, depending on what type of warnings or not found condition could occur in the called procedure.
if you do not have the right condition handler for the error in the calling procedure, it will probably terminate on the error. not sure if this is what your question is or not.