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.
- Expand the
Tables folder.
- Right-click the
table to which to add the trigger, and select
.
The
Create Trigger Skeleton page appears.
-
Choose the
SQL dialect you are using:
Transact-SQL or
Watcom-SQL.
-
Enter the name of the trigger in the
Name field.
For example, titleInsert. Enter the Order Number if you are using Watcom SQL. The
Order
clause determines the order in which triggers of the same type (
insert,
update, or
delete) are fired.
-
Enter an optional description in the
Comments field, and click
Next.
-
In the
Execution event handler field, select
For update,
For insert, or
For delete to indicate the condition under which the trigger is to be invoked when the associated table is modified.
-
If you are using Watcom SQL, you can select
For Update Columns, and choose the check boxes of columns that you want updated when the trigger is invoked.
- If you are using Watcom SQL, 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 have specified row-level isolation, the name you enter here refers to inserted row values after an update or insert. If you have specified 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 specified row-level isolation, the name you enter here refers to the values of a row before an update or delete. If you have specified 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 for the trigger.
Field |
Description |
Generate script |
Select this option to generate the script for the trigger. |
Enter or select the parent folder |
Specify an existing project or create a new project in
which to save the SQL. |
File name |
Enter the name of the file in which to store the
SQL. |
Execute immediately |
Execute the SQL immediately. If you do not select this
option, you must complete execution of the SQL later to create the trigger. |
Open in editor after creation |
Create the trigger, and then open it in the Trigger Editor. |
- Click
Finish to create the trigger.
The newly created trigger
is opened automatically in the Trigger Editor.
Send your feedback on this help topic to Sybase Technical Publications:
pubs@sybase.com
Your comments will be sent to the technical publications staff at Sybase, Inc.
For product-related issues or technical support, contact Sybase Technical Support
at 1-800-8SYBASE.