Previous Topic: Handling Numeric ErrorsNext Topic: Using SQLCA for SQL


Executing the Error Procedure for User-Determined Errors

You can execute the error procedure when program code determines that an error condition exists, even if the condition is not one that would cause a fatal error. To execute the error procedure, enter the statement DO ERROR.

The following example shows an error procedure being invoked:

<<COLOR_CHECK>> PROCEDURE
   SELECT WOR-COLOR
   WHEN 'BLUE'
      DO PROCESS‑BLUE
   WHEN 'RED'
      DO PROCESS‑RED
   WHEN 'YELLOW'
      DO PROCESS‑YELLOW
   WHEN OTHER
      DO ERROR
  ENDSEL
ENDPROC