Create a SQL Anywhere trigger to enforce a referential integrity constraint in a SQL Anywhere database.
Prerequisites
Before you can create a trigger, be sure the data server that contains the trigger is
running, and you created and established a connection to the data
server.
- In the Databases folder in Enterprise Explorer, under the database connection profile,
expand
the
tree for a database, expand the
Schemas folder and then the tree for the appropriate schema owner.
- Expand the
Tables folder.
- Right-click the
table to which to add the trigger, and select
.
-
Choose the
SQL Dialect:
Transact-SQL or
Watcom-SQL.
-
Enter the Name.
For example, titleInsert.
- (Watcom-SQL only) Enter the Order Number.
The
Order
clause determines the order in which triggers of the same type (insert,
update, or
delete) are fired.
-
(Optional)
Enter a description in the
Comments field, and click
Next.
-
For
Execution Event Handler, select
For Update,
For Insert, or
For Delete to indicate the condition under which the trigger invokes when the associated table is modified.
-
(Watcom-SQL only) Select
For Update Columns, and select the columns that you want updated when the trigger is invoked.
- (Watcom-SQL only) Click Next, and provide additional information for the trigger.
Field |
Description |
Trigger Level |
Specify the trigger isolation level as either Row level or Statement level. |
Trigger Time |
Specify the trigger firing time as either Before or After the specified row or statement is altered or executed. |
Referencing |
Specify the data to be referenced:
- New Row(s) – if you specify row-level isolation, the name you enter here refers to inserted row values after an update or insert. If you have specify statement-level isolation, the name you enter here refers to
declared temporary tables holding the old and new values of the rows.
- Old Row(s) – if you have specify row-level isolation, the name you enter here refers to the values of a row before an update or delete. If you have specify statement-level isolation, the name you enter here refers to
declared temporary tables holding the old and new values of the rows.
|
- Click
Next and specify save and execution
properties.
Field |
Description |
Generate Script |
Generate a SQL file for the object. |
Enter or Select the Parent Folder |
Specify an existing project or create a new project in
which to save the SQL file. |
File Name |
Enter the file name in which to store the
SQL code. |
Execute Immediately |
Execute the SQL code immediately. If you do not select this
option, you must complete execution of the SQL file later to create the object. |
Open in Editor After Creation |
Create the object and open it in its associated editor. |
- Click
Finish to create the trigger.
The newly created trigger
is opened automatically in the Trigger Editor.