ALLBASE/SQL Reference Manual (36216-90216)

Chapter 2 69
Using ALLBASE/SQL
Defining How Data is Stored and Retrieved
PartsDBE:
CREATE PROCEDURE PurchDB.DelSupply(Part CHAR(16) NOT NULL) AS
BEGIN
DELETE FROM PurchDB.SupplyPrice
WHERE PartNumber = :Part;
END
The procedure definition includes a parameter declaration. The parameter Part accepts a
value into the procedure at run time. You execute the procedure with a statement like the
following example:
EXECUTE PROCEDURE PurchDB.DelSupply ('1123-P-01')
The effect of the procedure is to delete all rows in the SupplyPrice table whose part
number is 1123-P-01. For detailed information about creating and using procedures, refer
to Chapter 4 , “Constraints, Procedures, and Rules.
Creating Rules
Once a table is defined, you can create a rule that will execute a procedure whenever a
specific firing condition is met. For example, you can define a rule that will execute a
procedure to delete rows from the SupplyPrice table whenever a specific part is dropped
from the Parts table in the sample DBEnvironment PartsDBE:
CREATE RULE PurchDB.RemovePart AFTER DELETE FROM PurchDB.Parts
EXECUTE PROCEDURE PurchDB.DelSupply (PartNumber)
Once the rule exists, you activate it by performing a DELETE:
DELETE FROM PurchDB.Parts
WHERE PartNumber = '1123-P-01'
For detailed information about creating and using rules, refer to the “Constraints,
Procedures, and Rules” chapter.