skip to main content
OpenEdge Data Management: DataServer for ODBC
Programming Considerations : Stored procedures : Handling errors from stored procedures
 

Handling errors from stored procedures

The RUN STORED–PROC statement supports the NO–ERROR option. The following example shows how to trap errors within a procedure:
DEFINE VARIABLE ix AS INTEGER NO-UNDO.
RUN STORED-PROC send-sql-statement NO-ERROR
   ("select count (*) from xxx.customer where name between 'A' and 'Z' ").
IF ERROR-STATUS:ERROR THEN DO:
   DO ix = 1 TO ERROR-STATUS:NUM-MESSAGES:
     MESSAGE "error" ERROR-STATUS:GET-NUMBER(ix)
     ERROR-STATUS:GET-MESSAGE(ix).
   END.
END.
FOR EACH proc-text-buffer.
DISPLAY proc-text-buffer.
END.
CLOSE STORED-PROC send-sql-statement.