Triggers are a named set of precompiled SQL statements stored on the server that are automatically executed when a specific event occurs. For example, a trigger can be executed when a row in a table is inserted, updated, or deleted. The trigger tells the DBMS how to process the SQL INSERT, UPDATE, or DELETE commands to enforce business rules.
The trigger structure consists of the following components:
Snippets may be built-in Default Templates, RI-Type Override Templates, Relationship Override Templates, or user-created code that is directly entered through the Table Trigger Editor.
Trigger templates are written in the default macro language and expand to the DBMS-specific code for each particular relationship. You can also use macros to customize the RI trigger templates and override the default code that is generated. The Macro Toolbox allows you to select a macro to add to the trigger. You can open the Macro Toolbox from the Code tab that is in the different Trigger Editors (such as the Server Trigger Editor or Database Trigger Editor).
Some of the commonly used trigger code includes %JoinFKPK(<child table>,<parent table>) and %NotNullFK(<child table>,<not null expression>).
Note: You can use options in the Model Editor, RI Defaults tab to specify default referential integrity rules for a model. When you generate the schema, you can select trigger options to control how the DDL is generated.
Copyright © 2017 erwin Inc.
All rights reserved.
|
|