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]]);
Specifies a string literal or a non-null host string variable.
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.
Changes the default destination of the message, which is a window at the bottom of the screen. Alternate destinations are as follows:
Directs the output of the message statement to the security audit log.
For example: WITH DESTINATION = (AUDIT_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.
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.
All users are permitted to use this statement.
The following are Message statement examples:
message 'Inserting new row';
insert into tab values (:val);
message 'About to commit change';
commit;
message 'Deleting newly inserted row';
delete from tab where tabval = :val;
message 'Returning with pending change';
return;
if iierrornumber > 0 then
message 58001;
elseif iirowcount <> 1 then
message 58002;
endif;
message 'User attempting to update payroll table'
with destination = (error_log);