Returning a completion status to the calling program

SQL and external procedures return status information to the calling program in different ways.

For SQL procedures, any errors that are not handled in the procedure are returned to the caller in the SQLCA. The SIGNAL and RESIGNAL control statements can be used to send error information as well.

For external procedures, there are two ways to return status information. One method of returning a status to the SQL program issuing the CALL statement is to code an extra INOUT type parameter and set it before returning from the procedure. When the procedure being called is an existing program, this is not always possible.

Another method of returning a status to the SQL program issuing the CALL statement is to send an escape message to the calling program (an operating system program) which calls the external procedure. Each language has methods for signalling conditions and sending messages. Refer to the respective language reference to determine the proper way to signal a message. When the message is signalled, the error is returned as SQLCODE/SQLSTATE -443/38501.