Message Handling Using the Whenever Statement
If your application does not include an SQLCA, messages from database procedures are displayed on the terminal. If your application includes an SQLCA, use the WHENEVER statement to trap and handle messages from database procedures. If your application includes an SQLCA, messages are displayed only if your application issues the WHENEVER SQLMESSAGE CALL SQLPRINT statement.
The WHENEVER statement handles the following scenarios:
• All messages returned from directly executed database procedures
• The last message returned from a procedure called when a rule is fired
Messages issued by database procedures return message text and a message number to the calling application, and set sqlcode to +700.
Note: If a database procedure issues a MESSAGE statement and subsequently raises an error, the WHENEVER SQLMESSAGE does not trap the message. To trap all messages, use a message handler routine.