MESSAGE Statement

Displays a message, which can be any expression. Clauses can specify where the message is displayed.

Quick Links:

Go to Parameters

Go to Examples

Go to Usage

Go to Standards

Go to Permissions

Syntax

MESSAGE expression, …
   [ TYPEINFO | ACTION | WARNING | STATUS } ]
   [ TOCONSOLE 
      | CLIENTFOR { CONNECTION conn_id [ IMMEDIATE ] | ALL } ]
      | [ EVENT | SYSTEM ] LOG } 
   [ DEBUG ONLY ] ]

Parameters

(back to top)

Examples

(back to top)

Usage

(back to top)

The procedure issuing a MESSAGE … TO CLIENT statement must be associated with a connection.

For example, the message box is not displayed because the event occurs outside of a connection:

CREATE EVENT CheckIdleTime TYPE ServerIdle 
WHERE event_condition( 'IdleTime' ) > 100 
HANDLER 
BEGIN    
  MESSAGE 'Idle engine' type warning to client; 
END;

However, in this example, the message is written to the server console:

CREATE EVENT CheckIdleTime TYPE ServerIdle 
WHERE event_condition( 'IdleTime' ) > 100 
HANDLER 
BEGIN   
  MESSAGE 'Idle engine' type warning to console; 
END;

Valid expressions can include a quoted string or other constant, variable, or function. However, queries are not permitted in the output of a MESSAGE statement, even though the definition of an expression includes queries.

ESQL and ODBC clients receive messages via message callback functions. In each case, these functions must be registered. To register ESQL message handlers, use the db_register_callback function.

ODBC clients can register callback functions using the SQLSetConnectAttr function.

Standards

(back to top)

  • SQL—Vendor extension to ISO/ANSI SQL grammar.
  • SAP Sybase Database product—Not supported in Adaptive Server. The Transact-SQL PRINT statement provides a similar feature, and is available in SQL Anywhere.

Permissions

(back to top)

Must be connected to the database.

Related reference
CREATE PROCEDURE Statement
WAITFOR Statement
DEBUG_MESSAGES Option