Return status values

Return status values are returned as a CS_STATUS_RESULT result set (see “Processing return status results”).

NoteSQL statements that return a result type of CS_CMD_FAIL when executed by a language command may return CS_CMD_SUCCEED when executed by a stored procedure. Always check a stored procedure’s return status to determine whether the procedure executed successfully.

If a procedure successfully completes execution, the return status is either the value explicitly returned by the procedure or 0 if the procedure lacks an explicit return statement. However, some runtime errors cause a stored procedure to abort before it executes to completion. For example, a select statement in the procedure may refer to a table that no longer exists. For these errors, Adaptive Server aborts the execution of the procedure and returns a return status value that indicates the error—see the return reference page in the Adaptive Server Enterprise Reference Manual for a list of return status codes and their meaning.

When a runtime error occurs inside a stored procedure, Adaptive Server does not return a result type of CS_CMD_FAIL. To determine whether a server-side error has occurred inside the procedure, applications should always check the return status of the stored procedure. Adaptive Server also sends server messages that describe runtime errors.