Trigger template items are named reusable blocks of script that can be inserted into triggers or trigger templates. In a generated trigger script, a template item calls a macro that implements a trigger referential integrity constraint or does any other updating work on tables in the database.
To insert a trigger template item into your trigger or template definition, click the Add Trigger Item from Model or Add Trigger Item from DBMS tool, select the items from the list and click OK. The item is inserted with a dot followed by its name, and is also added to the list on the Template Items tab. 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 /
.Decltemplate item nameFor example, the trigger definition for Oracle 8 declares and then inserts the .InsertChildParentExist template item:
-- Before insert trigger "[%QUALIFIER%]%TRIGGER%" for table "[%QUALIFIER%]%TABLE%" create trigger [%QUALIFIER%]%TRIGGER% before insert on [%QUALIFIER%]%TABLE% for each row declare integrity_error exception; errno integer; errmsg char(200); dummy integer; found boolean; .DeclInsertChildParentExist begin .InsertChildParentExist -- Errors handling exception when integrity_error then raise_application_error(errno, errmsg); end; /
The General tab contains the following properties:
Property |
Description |
---|---|
Name/Code/Comment |
Identify the object. The name should clearly convey the object's purpose to non-technical users, while the code, which is used for generating code or scripts, may be abbreviated, and should not normally include spaces. You can optionally add a comment to provide more detailed information about the object. By default the code is generated from the name by applying the naming conventions specified in the model options. To decouple name-code synchronization, click to release the = button to the right of the Code field. |
DBMS |
Specifies the parent DBMS. |
Keywords |
Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them with commas. |