7. Understanding Database Procedures, Sessions, and Events : How Database Procedures Are Created, Invoked, and Executed : Messages from Database Procedures : Message Handling Using User-Defined Handler Routines
 
Share this page                  
Message Handling Using User-Defined Handler Routines
To define a message handler routine, use the SET_SQL MESSAGEHANDLER statement. Routines defined this way can trap all messages returned by procedures that are executed by rules; the WHENEVER statement traps only the last message.
To enable or disable a message-handling routine, your application must issue the following SET_SQL statement:
EXEC SQL SET_SQL(MESSAGEHANDLER = message_routine | 0)
To enable message handling, specify message_routine as a pointer to your message-handling routine or function. (For more information about pointers to functions, see the Embedded SQL Companion Guide.) To disable message handling, specify 0.
In addition to issuing the SET_SQL statement shown above, create the message-handling routine and link it with your embedded SQL application.