Trigger Templates

PowerDesigner trigger templates allow you to write trigger code in a modular reusable fashion. We provide basic templates for before, after, and with insert, update, and delete events and for other types of triggers where supported by the DBMS. You can modify the code specified in these templates or create your own templates in the DBMS definition file or in your model.

To apply a trigger template to your trigger definition, select the template from the list on the trigger property sheet Definition tab (see Trigger and DBMS Trigger Properties).

To review or modify the provided trigger templates, select Database > Edit Current DBMS, and then click the Trigger Templates tab. You cannot delete or rename these templates.
Warning!  The resource files provided with PowerDesigner inside the Program Files folder cannot be modified directly. To create a copy for editing, use the New tool on the resource file list, and save it in another location. To include resource files from different locations for use in your models, use the Path tool on the resource file list.
To create a new template, click the Create from Trigger Template tool (to copy the code of an existing template to your new template) or the Add a Row tool (to start from scratch).
Note: You can, alternatively, create trigger templates in your model by selecting Model > Triggers > Trigger Templates, but these templates will not be accessible from other models.

Trigger Template Properties

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.

Applies to

[for DBMSs supporting multiple types of triggers] Specifies whether the template can be applied to table, view, or DBMS triggers.

Trigger time

Specifies when triggers based on the template will fire in relation to their associated event.

Trigger event

Specifies the event that will cause the firing of triggers based on the template.

Trigger name

Specifies the conventions for naming triggers based on the template.

Keywords

Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them with commas.

The following tabs are also available:
  • Definition - Contains a field for entering the trigger code for the template.You can use trigger template items, PDM variables and macros and other tools available from the toolbar (see Writing SQL Code in PowerDesigner).
  • Template Items - Lists the template items (see Trigger Template Items) that are defined in the trigger template and that will be generated when a trigger is generated from the template.
    Note: If you delete a template item from this list, it is not deleted from the template definition, but is excluded from generation when rebuilding triggers. PowerDesigner-provided template items listed on this tab are generated in a trigger if they match the trigger implemented referential integrity defined for a reference attached to the table. User-created template items are always generated regardless of trigger referential integrity constraints.