SQL Language Guide : 8. SQL Statements : MESSAGE
 
Share this page                  
MESSAGE
Valid in: DBProc
The MESSAGE statement returns message text and a message number from a database procedure to an application program. The message statement can only be issued from a database procedure.
The MESSAGE statement has the following format:
MESSAGE message_text | message_number | message_number message_text
              [WITH DESTINATION =([SESSION][, ERROR_LOG] [, AUDIT_LOG]]);
message_text
Specifies a string literal or a non-null host string variable.
Limits: The maximum length is 1500 bytes.
message_number
Specifies an integer literal or a non-null host integer variable.
Neither message_text nor message_number can be expressions. The values for these parameters do not correspond to DBMS Server error codes or messages; the message statement simply returns the specified values to the receiving application. If the message_number parameter is omitted, the DBMS Server returns a value of 0.
WITH DESTINATION
Changes the default destination of the message, which is a window at the bottom of the screen. Alternate destinations are as follows:
AUDIT_LOG
Directs the output of the message statement to the security audit log.
For example: WITH DESTINATION = (AUDIT_LOG)
ERROR_LOG
Directs the output of the message statement to the error log.
The message number and text is written to errlog.log with message identifier E_QE0300.
SESSION
Restores the default behavior.
To both log and return messages to the application, specify WITH DESTINATION = (SESSION, ERROR_LOG).
To specify an action to be performed when an application receives a message from a database procedure, use the WHENEVER SQLMESSAGE statement. For details, see WHENEVER.
To specify a routine that is called when an application receives a message from a database procedure, use the SET_SQL(messagehandler) statement. For details, see SET_SQL.
Permissions
This statement is available to all users.
Related Statements
CREATE PROCEDURE
INQUIRE_SQL