Programming Guide



ONEXIT

Installs an exit handler

Synopsis

DBMS ONEXIT CALL function
DBMS ONEXIT JPL jplEntryPoint
DBMS ONEXIT STOP

Arguments

CALL function
Name of prototyped C function.

JPL jplEntryPoint
Name of JPL procedure.

STOP
Remove any installed exit function.

Use DBMS ONEXIT to install a function which Panther calls after executing a DBMS command from JPL or C. Use this function to process error and status codes after every command.

The exit handler is global to the application. Each execution of DBMS ONEXIT overrides the previous exit handler.

The function is passed three arguments:

  1. The first 255 characters of the statement. If the statement was executed from JPL, this is the first 255 characters after the command word DBMS or DBMS SQL.
  2. The name of the database engine for the statement.
  3. Context flag; for the exit handler its value is 1.

The function's return code is returned to the application. If an ONEXIT function and an ONERROR function are both installed, the return code from the ONERROR function takes precedence.

If an error occurred while executing a JPL statement with a DBMS command and there is no ONEXIT function, then

If the error occurred while executing a statement with the dm_dbms library function and there is an ONEXIT function, the function returns the exit handler's return code.

To use a C function as an exit handler, you must first install the function as a prototyped function. For more information, refer to "Prototyped Functions" in Application Development Guide.

Example

//JPL procedure processes warnings from the database engine.
proc entry
DBMS ONEXIT JPL dbi_warn
return
proc dbi_warn (stmt, engine, flag)
if @dmengerrcode == 0
msg emsg stmt "%N" "Error: " @dmretmsg
else
msg emsg stmt "%N" "Error: " @dmretmsg "%N" \
":engine error: " @dmengwarncode " " @dmengwarnmsg
return

See Also

ONENTRY, ONERROR, Chapter 12, "DBMS Global Variables," Chapter 37, "Processing Application Errors," in Application Development Guide