9. Ensuring Data Integrity : Rules : Enforcing General-Purpose Rules : Using a Rule to Apply External Resource Controls
 
Share this page                  
Using a Rule to Apply External Resource Controls
You can use general purpose rules to apply external resource controls.
For example, if you have a table of items in stock, define a rule that fires after an update to the in_stock column. The following WHERE clause causes the rule to fire if the number of items in stock is reduced to less than a minimum value of 100:
items.in_stock < 100
The rule executes a database procedure that reorders the item responsible for firing the rule, passing as parameters an item identifier and the number of items in stock. For example:
id = items.id, items_left = items.in_stock