Chapter 5 Building Triggers and Procedures
Inserting a template item into a trigger or trigger template
Template items are inserted in a trigger or trigger template definition using a dot followed by the template item name. For example, the following script contains two template items InsertChildParentExist
and InsertTooManyChildren:
/* Before insert trigger "%TRIGGER%" for table "[%QUALIFIER%]%TABLE%" */
create trigger %TRIGGER% before insert order %ORDER% on [%QUALIFIER%]%TABLE%
referencing new as new_ins for each row
begin
declare user_defined_exception exception for SQLSTATE '99999';
declare found integer;
.InsertChildParentExist
.InsertTooManyChildren
end
/
To add a template item to a trigger or trigger template:
- Open the property sheet of the trigger or trigger template that you want to modify, and then click the Definition tab.
- Click at the point in the code where you want to insert the trigger template item, and then click one of the following tools:
- Add Trigger Item From DBMS – to open a selection box containing a list of trigger template items defined in the DBMS definition file
- Add Trigger Item From Model – to open a selection box containing a list of trigger template items defined in the model
- Select the item to insert and then click OK to return to the definition tab.
The trigger template item will be inserted in your code. It will also appear in the list on the Template Items tab.
Copyright (C) 2005. Sybase Inc. All rights reserved.
|
|