Chapter 5 Building Triggers and Procedures


Trigger Overview

A trigger is a segment of SQL code associated with a table or a view, and stored in a database. It is invoked automatically whenever there is an attempt to modify data in the associated table with an insert, delete, or update command.

Triggers enhance the security, efficiency, and standardization of databases.

You can use triggers to enforce referential integrity, where declarative constraints are not sufficient. You can also use triggers to implement sequences for columns.

Trigger templates and template items

A trigger template is a pre-defined form for creating triggers. PowerDesigner ships templates for each supported DBMS. Depending on the current DBMS, there are pre-defined templates for insert, update, and delete trigger types.

A template item is a reusable block of SQL script that can implement referential integrity, or do any other work on database tables. PowerDesigner ships template items for each supported DBMS. A template item is inserted into a trigger template script, or a trigger script. The template item calls a corresponding SQL macro which can implement an insert, update, delete, or error message constraint on one or more tables in the database.

You can use the PowerDesigner templates and template items, copy and edit them, or create your own from scratch. For more information, see "Working with Trigger Templates and Template Items".

 


Copyright (C) 2005. Sybase Inc. All rights reserved.