Chapter 5 Building Triggers and Procedures
PowerDesigner ships pre-defined template items for each pre-defined trigger template defined in the supported DBMS. The Rebuild Triggers function uses both pre-defined and user-defined trigger templates to automatically create triggers for selected tables.
In the pre-defined trigger templates, each pre-defined template item corresponds to a referential integrity constraint. Although a pre-defined template item is defined in a trigger template, it is only generated in a trigger script if it implements the trigger referential integrity defined for a reference.
Template items have the following generation conditions:
Template item is listed in... | Template item is... |
---|---|
Template Items page of trigger property sheet | Available for generation |
Template Items page of trigger template property sheet | Generated |
You can modify the code for these pre-defined template items, but they cannot be deleted or renamed.
The PowerDesigner pre-defined template items that are available depend on the current DBMS.
The template items below implement referential integrity in insert trigger templates.
Template item |
Integrity constraint | Description |
---|---|---|
DeclInsertChildParentExist InsertChildParentExist |
Mandatory parent | Parent must exist when inserting a child |
DeclInsertTooManyChildren InsertTooManyChildren |
Cannot exceed maximum cardinality constraint | Cannot insert a child if maximum cardinality has been reached |
DeclInsertSequenceColumn InsertSequenceColumn |
Select value in sequence list for column | Select a value for the column from a list of sequences |
The template items below implement referential integrity in update trigger templates.
Template item |
Integrity constraint | Description |
---|---|---|
DeclUpdateChildParentExist
UpdateChildParentExist
|
Mandatory parent | Parent must exist when updating a child |
DeclUpdateChildChangeParent
UpdateChildChangeParent
|
Change parent not allowed | Cannot modify parent code in child |
DeclUpdateParentRestrict
UpdateParentRestrict
|
Restrict on update | Cannot modify parent if child exists |
DeclUpdateParentCascade
UpdateParentCascade
|
Cascade on update | Modify parent code in all children |
DeclUpdateChangeColumn
UpdateChangeColumn
|
Non-modifiable column | Cannot modify column |
DeclUpdateParentSetNull
UpdateParentSetNull
|
Set null on update | Set parent code to null in all children |
DeclUpdateParentSetDefault
UpdateParentSetDefault
|
Set default on update | Set parent code to default in all children |
DeclUpdateTooManyChildren
UpdateTooManyChildren
|
Cannot exceed maximum cardinality constraint | Cannot update a child if maximum cardinality has been reached |
The template items below implement referential integrity in delete trigger templates.
Template item |
Integrity constraint | Description |
---|---|---|
DeclDeleteParentRestrict
DeleteParentRestrict
|
Restrict on delete | Cannot delete parent if child exists |
DeclDeleteParentCascade
DeleteParentCascade
|
Cascade on delete | Delete parent code in all children |
DeclDeleteParentSetNull
DeleteParentSetNull
|
Set null on delete | Delete in parent sets child to null |
DeclDeleteParentSetDefault
DeleteParentSetDefault
|
Set default on delete | Delete in parent sets child to default |
You can insert the following template items in any trigger template. They generate error messages that indicate the violation of an integrity constraint.
Template item | Description |
---|---|
UseErrorMsgText | Error handling without a message table |
UseErrorMsgTable | Error handling with a message table |
Copyright (C) 2005. Sybase Inc. All rights reserved. |