Provides context information for event handlers.
EVENT_PARAMETER( context-name )
context-name : AppInfo | ConnectionID | DisconnectReason | EventName | Executions | MirrorServerName | NumActive | ScheduleName | SQLCODE | TableName | User | condition-name
context-name One of the preset strings. The strings must be quoted, are case insensitive, and carry the following information:
AppInfo The value of the AppInfo connection property for the connection that caused the event to be triggered. Use the following statement to see the value of the property outside the context of the event:
SELECT CONNECTION_PROPERTY( 'AppInfo' );
The AppInfo string contains the computer name and application name of the client connection for embedded SQL, ODBC, OLE DB, ADO.NET, and SQL Anywhere JDBC driver connections.
ConnectionID The connection ID of the connection that caused the event to be triggered.
DisconnectReason A string indicating the reason the connect was terminated. This parameter is valid only for Disconnect events. Possible results include:
abnormal A disconnect occurred as a result of the client application terminating abnormally before disconnecting from the database, or as a result of a communication failure between the client and server computers.
connect failed A connection attempt failed.
drop connection A DROP CONNECTION statement was executed.
from client The client application disconnected.
inactive No requests were received for the period specified by the -ti server option.
liveness No liveness packets were received for the period specified by the -tl server option.
EventName The name of the event that has been triggered.
Executions The number of times the event handler has been executed.
MirrorServerName The name of the mirror or arbiter server that lost its connection to the primary server in a database mirroring system.
NumActive The number of active instances of an event handler. This is useful for limiting an event handler so that only one instance executes at any given time.
ScheduleName The name of the schedule which caused an event to be fired. If the event was fired manually using TRIGGER EVENT or as a system event, the result will be an empty string. If the schedule was not assigned a name explicitly when it was created, its name is the name of the event.
SQLCODE The SQLCODE of the error that occurred during a failed connection. This parameter is valid only for ConnectFailed events.
TableName The name of the table, for use with RemainingValues.
User The user ID for the user that caused the event to be triggered.
In addition, you can access any of the valid condition-name arguments to the EVENT_CONDITION function from the EVENT_PARAMETER function.
The following table indicates which context-name values are valid for which system event types.
|System event types||Context-name value|
|BackupEnd||AppInfo, ConnectionID, EventName, Executions, NumActive, User|
|Connect||AppInfo, ConnectionID, EventName, Executions, NumActive, User|
|ConnectFailed||AppInfo, EventName, Executions, NumActive, SQLCODE, User|
|"Disconnect"||AppInfo, ConnectionID, EventName, Executions, NumActive, User|
|GlobalAutoincrement||ConnectionID, EventName, Executions, NumActive, TableName, User|
|"RAISERROR"||AppInfo, ConnectionID, EventName, Executions, NumActive, User|
|User events||AppInfo, ConnectionID, EventName, Executions, NumActive, User|
The maximum size of values passed to an event is limited by the maximum page size for the server (-gp server option). Values that are longer are truncated to be less than the maximum page size.
SQL/2008 Vendor extension.
The following example shows how to pass a string parameter to an event. The event displays the time it was triggered in the database server messages window.
CREATE EVENT ev_PassedParameter HANDLER BEGIN MESSAGE 'ev_PassedParameter - was triggered at ' || event_parameter( 'time' ); END; TRIGGER EVENT ev_PassedParameter( "Time"=string(current timestamp ) );
Discuss this page in DocCommentXchange.
|Copyright © 2014, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0|