Procedure Return Status

Stored procedures can return an integer value called a return status. The return status either indicates that the procedure executed successfully or specifies the type of error that occurred.

When you execute a stored procedure, it automatically returns the appropriate status code. The SAP ASE server currently returns these status codes:




Procedure executed without error


Missing object


Datatype error


Process was chosen as deadlock victim


Permission error


Syntax error


Miscellaneous user error


Resource error, such as out of space


Nonfatal internal problem


System limit was reached


Fatal internal inconsistency


Fatal internal inconsistency


Table or index is corrupt


Database is corrupt


Hardware error

Codes -15 through -99 are reserved for future use.

Users can generate a user-defined return status with the return statement. The status can be any integer other than 0 through -99. The following example returns 1 when a book has a valid contract and 2 in all other cases:
create proc checkcontract @titleid tid 
if (select contract from titles where 
        title_id = @titleid) = 1 
   return 1 
   return 2
checkcontract @titleid = "BU1111"
 (return status = 1)
checkcontract @titleid = "MC3026"
 (return status = 2)

If more than one error occurs during execution, the code with the highest absolute value is returned. User-defined return values take precedence over system-defined values.