MESSAGE Statement

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

Syntax

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

Parameters

Examples

Usage

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

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported in Adaptive Server Enterprise. The Transact-SQL PRINT statement provides a similar feature, and is available in SQL Anywhere.

Permissions

Must be connected to the database.

Related reference
CREATE PROCEDURE Statement
WAITFOR Statement
DEBUG_MESSAGES Option