Rule Dialog¶
Use the Rule dialog to define or modify a rule for a specified table or view. A PostgreSQL rule allows you to define an additional action that will be performed when a SELECT, INSERT, UPDATE, or DELETE is performed against a table.
The Rule dialog organizes the development of a rule through the General,
Definition, Condition, Commands tabs. The SQL tab displays the SQL code
generated by dialog selections.
Create Rule dialog - General tab¶
Use the fields in the General tab to identify the rule:
Use the
Namefield to add a descriptive name for the rule. The name will be displayed in theBrowsertree control. Multiple rules on the same table are applied in alphabetical name order.Store notes about the rule in the
Commentfield.
Click the Definition tab to continue.
Create Rule dialog - Definition tab¶
Use the fields in the Definition tab to write parameters:
Click inside the
Eventfield to select the type of event that will invoke the rule; event may beSelect,Insert,Update, orDelete.Move the
Do Insteadswitch toYesindicate that the commands should be executed instead of the original command; if Do Instead specifiesNo, the rule will be invoked in addition to the original command.
Click the Condition tab to continue.
Create Rule dialog - Condition tab¶
Specify a SQL conditional expression that returns a boolean value in the editor.
Click the Commands tab to continue.
Create Rule dialog - Commands tab¶
Provide a command in the editor that defines the action performed by the rule.
Click the SQL tab to continue.
Your entries in the Rule dialog generate a SQL command (see an example below). Use the SQL tab for review; revisit or switch tabs to make any changes to the SQL command.
Example
The following is an example of the sql command generated by user selections in the Rule dialog:
Create Rule dialog - SQL tab¶
The example sends a notification when an UPDATE executes against a table.
Click the
Infobutton (i) to access online help. View context-sensitive help in theTabbed browser, where a new tab displays the PostgreSQL core documentation.Click the
Savebutton to save work.Click the
Cancelbutton to exit without saving work.Click the
Resetbutton to restore configuration parameters.