Notes
Returning from a procedure:
- If a RETURN statement with a specified return value is used to return
from a procedure then the SQLCODE, SQLSTATE, and message length in the SQLCA
or diagnostics area are initialized to zeros, and message text is set to blanks.
An error is not returned to the caller.
- If a RETURN statement is not used to return from a procedure or if a value
is not specified on the RETURN statement,
- if the procedure returns with an SQLCODE that is greater than
or equal to zero, the specified target for DB2_RETURN_STATUS in a GET DIAGNOSTICS
statement will be set to a value of 0
- if the procedure returns with an SQLCODE that is less than
zero, the specified target for DB2_RETURN_STATUS in a GET DIAGNOSTICS statement
will be set to a value of -1.
- When a value is returned from a procedure, the caller may access the value
using:
- the GET DIAGNOSTICS statement to retrieve the DB2_RETURN_STATUS
when the SQL procedure was called from another SQL procedure
- the parameter bound for the return value parameter marker in the escape
clause CALL syntax (?=CALL...) in a CLI application
- directly from the SQLCA returned from processing the CALL of an SQL procedure
by retrieving the value of sqlerrd[0] when the SQLCODE is
not less than zero. When the SQLCODE is less than zero, the sqlerrd[0]
value is not set and the application should assume a return status value
of -1.
RETURN restrictions:
- RETURN is not allowed in SQL triggers.
- Only one RETURN statement is allowed in an SQL table function statement routine-body.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.