Handling errors
- Last Updated: February 11, 2026
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
The RUN STORED-PROC statement supports the NO-ERROR option.
Trapping errors within a procedure using NO-ERROR option (simple example)
The following shows a simple example how to trap errors within a procedure using the
NO-ERROR option.
|
Trapping errors within a procedure using NO-ERROR option
The following example assumes that you created the sp_img table and
defined the sp_img_out stored procedure with two data types, integer and
image, in the MS SQL Server as shown in the following code samples:
|
|
In the ABL code example that follows, the first (input) parameter literal value "3" is
mapped to an INTEGER data type and the second (output) parameter "picture"
is mapped to an IMAGE data type in MS SQL Server. As the ODBC drivers and
the stored procedures in MS SQL Server do not support the legacy data type
IMAGE as an OUTPUT parameter, on executing the
sp_img_out stored procedure with the NO-ERROR option, a
run-time error results, and is handled by the ERROR-STATUS:ERROR check in
the IF block.
IMAGE is not an unsupported data type. It is unsupported only as an OUTPUT
parameter.
|
The DataServer internally closes the stored procedure handle when the stored procedure
fails to execute. You must ensure that the error handling code block immediately follows the
RUN STORED-PROCEDURE call so that errors captured by
NO-ERROR are not lost by the execution of another statement. Including
the CLOSE STORED-PROCEDURE statement in the error handling block causes a
run-time error because closure is implicit. Only if the procedure is run successfully will a
procedure handle be established, and only then do you need to execute CLOSE
STORED-PROCEDURE on the open handle.
Trapping errors within a procedure using CATCH option
The error demonstrated in the previous example can also be handled using a
CATCH end block in the procedure block that performs the RUN
STORED-PROC statement. The following code shows how to trap errors within a
procedure using a CATCH end block.
|
For more information on the NO-ERROR option, CATCH statement or CATCH end block, in OpenEdge ABL, see OpenEdge Development: ABL Reference.