Was this helpful?
How You Define an Error Handler
An error handling function can be defined to be called when OpenSQL errors occur. To do this, you must:
Write the error handling routine and link it into your embedded OpenSQL application.
In the application, issue the following SET statement:
exec sql set_sql(errorhandler = error_routine)
where:
error_routine is the name of the error‑handling routine you created. Do not declare error_routine in an OpenSQL declare section, and do not precede error_routine with a colon (:). The error_routine argument must be a function pointer.
When this form of error‑trapping is enabled, all OpenSQL errors are trapped to your routine until you disable error‑trapping (or until the application terminates). Forms errors are not trapped.
To disable the trapping of errors to your routine, your application must issue the following set statement:
exec sql set_sql(errorhandler = 0 | :error_var)
where error_var is a host integer variable having a value of 0.
Your error‑handling routine must not issue any database statements in the same session in which the error occurred. If it is necessary to issue database statements in an error handler, open a session or switch to another session.
To obtain error information, your error‑handling routine should issue the INQUIRE_SQL statement.
Last modified date: 04/03/2024