SYS_MGR.DBMS_ERRORCODE

How to:

The SYS_MGR.DBMS_ERRORCODE command enables you to retrieve error codes returned by the DBMS server and then take appropriate action. For example, a developer might want to take a different course of action for an INSERT that fails because the user does not have INSERT rights versus a referential integrity failure.

Note:
  • The return codes are DBMS specific. The DB2 return codes do not match the Oracle return codes. Moreover, DBMS vendors have been known to change the return codes on release boundaries. You should clearly document that you are using this feature so sufficient testing can be done before rolling in a new DBMS.
  • DBMS_ERRORCODE is local to the current Maintain procedure.

Syntax: How to Use SYS_MGR.DBMS_ERRORCODE

The syntax is

SYS_MGR.DBMS_ERRORCODE ;

Example: Retrieving an Error Code From a DBMS

For example, the following Maintain code will retrieve an error code from a DBMS, and if it is a specific code, branches to some appropriate code:

Compute ErrCode/a3 = SYS_MGR.DBMS_ERRORCODE ;
If ErrCode EQ '515' goto BadInsert;

WebFOCUS

Feedback