Define PostgreSQL Triggers
PostgreSQL supports table and view triggers. Use the table or view trigger editor to define a trigger.
To define a PostgreSQL trigger
- In the Model Explorer, under Tables or views, right-click Triggers and click New.
An instance of Trigger is created.
- Right-click the instance and click Properties.
The PostgreSQL Trigger Editor opens.
- In the navigation grid, select the trigger that you want to define and work with the following options:
Click New on the toolbar to create a trigger. Use the Enter filter text box to filter a very large list of triggers to quickly locate the one that you want to define.
- Name
Specifies the name of the view or table trigger. Change the name of the trigger in this field.
- Fire
Specifies when the trigger function should be called.
- Generate
Generates SQL during forward engineering. Clear the check box if you do not want to generate SQL.
- On the PostgreSQL tab, work with the following options:
- Row Trigger
Indicates that the trigger is a row trigger.
- Constraint Trigger
Indicates that the trigger is a constraint trigger. The timing of trigger firing can be adjusted by setting constraints.
- Deferrable
Indicates whether the constraint can be deferred.
- Initially Deferred
Specifies the default time to check the constraint in case of a deferrable constraint. It is checked only at the end of the transaction.
- Function
Specifies the function that is declared as taking no arguments and returning type trigger, which is executed when the trigger fires. Select a function from the drop-down list or click New to create one.
- Type
Specifies the type of even on which the trigger will be fired.
- When
Specifies the condition on which the trigger should execute.
- Column
Specifies a list of columns. It indicates that the trigger will only fire if at least one of the listed columns is mentioned as a target of the UPDATE command.
- Work with the other tabs in the editor to access additional design features, for example:
- (Optional) Click the Comment tab and enter any comments that you want to associate with the object.
- (Optional) Click the UDP tab to work with user-defined properties for the object.
- (Optional) Click the Notes tab to view and edit user notes.
- Click Close.
The trigger is defined and the PostgreSQL Trigger Editor closes.
For more information on trigger properties, refer to PostgreSQL documentation.
Copyright © 2024 Quest Software, Inc. |