2016-05-27 11:13:36 -05:00
|
|
|
.. _rule_dialog:
|
|
|
|
|
2018-06-15 03:14:12 -05:00
|
|
|
********************
|
|
|
|
`Rule Dialog`:index:
|
|
|
|
********************
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
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.
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The *Rule* dialog organizes the development of a rule through the *General*,
|
2019-08-12 03:57:02 -05:00
|
|
|
*Definition*, *Condition*, *Commands* tabs. The *SQL* tab displays the SQL code
|
|
|
|
generated by dialog selections.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
.. image:: images/rule_general.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Rule dialog general tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
Use the fields in the *General* tab to identify the rule:
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the *Name* field to add a descriptive name for the rule. The name will be
|
|
|
|
displayed in the *pgAdmin* tree control. Multiple rules on the same table are
|
|
|
|
applied in alphabetical name order.
|
2016-05-27 11:13:36 -05:00
|
|
|
* Store notes about the rule in the *Comment* field.
|
|
|
|
|
|
|
|
Click the *Definition* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/rule_definition.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Rule dialog definition tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
Use the fields in the *Definition* tab to write parameters:
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Click inside the *Event* field to select the type of event that will invoke
|
|
|
|
the rule; event may be *Select*, *Insert*, *Update*, or *Delete*.
|
|
|
|
* Move the *Do Instead* switch to *Yes* indicate that the commands should be
|
|
|
|
executed instead of the original command; if Do Instead specifies *No*, the
|
|
|
|
rule will be invoked in addition to the original command.
|
2019-08-12 03:57:02 -05:00
|
|
|
|
|
|
|
Click the *Condition* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/rule_condition.png
|
|
|
|
:alt: Rule dialog condition tab
|
|
|
|
:align: center
|
|
|
|
|
|
|
|
Specify a SQL conditional expression that returns a boolean value in the editor.
|
|
|
|
|
|
|
|
Click the *Commands* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/rule_commands.png
|
|
|
|
:alt: Rule dialog commands tab
|
|
|
|
:align: center
|
|
|
|
|
|
|
|
Provide a command in the editor that defines the action performed by the rule.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
Click the *SQL* tab to continue.
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
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.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Example
|
|
|
|
*******
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The following is an example of the sql command generated by user selections in
|
|
|
|
the *Rule* dialog:
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
.. image:: images/rule_sql.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Rule dialog sql tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2018-01-11 10:58:30 -06:00
|
|
|
|
|
|
|
The example sends a notification when an UPDATE executes against a table.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Click the *Info* button (i) to access online help.
|
2016-05-27 11:13:36 -05:00
|
|
|
* Click the *Save* button to save work.
|
|
|
|
* Click the *Cancel* button to exit without saving work.
|
2016-06-21 03:06:44 -05:00
|
|
|
* Click the *Reset* button to restore configuration parameters.
|