Defining Trigger Conditions for Events

Each event definition has a system event associated with it. It also has one or more trigger conditions.

The event handler is triggered when the trigger conditions for the system event are satisfied.

Note:

The trigger conditions associated with Sybase IQ events are not the same as SQL Anywhere or Adaptive Server Enterprise triggers, which execute automatically when a user attempts a specified data modification statement on a specified table.

SeeSQL Anywhere 11.0.1 > SQL Anywhere Server - Database Administration > Maintaining Your Database > Automating tasks using schedules and events > Understanding system events > Defining trigger conditions for events.

Sybase IQ Example

Note:

For examples, use the Sybase IQ demo database iqdemo.db.

create event SecurityCheck
type ConnectFailed
handler
begindeclare num_failures int;declare mins int;

insert into FailedConnections( log_time )values ( current timestamp );
select count( * ) into num_failuresfrom FailedConnectionswhere log_time >= dateadd( minute, -5, 
	current timestamp );if( num_failures >= 3 ) then
	select datediff( minute, last_notification,		current timestamp ) into mins	from Notification;
	if( mins > 30 ) then		update Notification		set last_notification = current timestamp;		call xp_sendmail( recipient='DBAdmin',				subject='Security Check',"message"=		'over 3 failed connections in last 5 minutes' )	end ifend ifend