Creating triggers

The body of a trigger consists of a compound statement: a set of semicolon-delimited SQL statements bracketed by a BEGIN and an END statement.

 Create a trigger for a given table (Sybase Central)

You must have DBA or RESOURCE authority to create a trigger and you must have ALTER permissions on the table associated with the trigger.

  1. Use the SQL Anywhere 12 plug-in to connect to the database as a user with DBA or Resource authority.

  2. In the left pane, click Triggers.

  3. Click File » New » Trigger.

  4. Follow the instructions in the Create Trigger Wizard.

  5. To complete the code, in the right pane click the SQL tab.

 Create a trigger for a given table (SQL)

You must have DBA or RESOURCE authority to create a trigger and you must have ALTER permissions on the table associated with the trigger.

You cannot use COMMIT and ROLLBACK and some ROLLBACK TO SAVEPOINT statements within a trigger.

  1. Connect to a database as a user with DBA authority. You must also have ALTER permissions on the table associated with the trigger.

  2. Execute a CREATE TRIGGER statement.

 Example 1: A row-level INSERT trigger
 Example 2: A row-level DELETE trigger example
 Example 3: A statement-level UPDATE trigger example
 See also