ALLBASE/SQL Reference Manual (36216-90216)

Chapter 11 443
SQL Statements E - R
IF
Example
Create a procedure to enter orders into different tables according to the size of the order:
CREATE PROCEDURE OrderEntry (PartName CHAR(20) NOT NULL,
Quantity INTEGER NOT NULL) AS
BEGIN
IF :Quantity < 100 THEN
INSERT INTO SmallOrders
VALUES (:PartName, :Quantity);
ELSE
INSERT INTO LargeOrders
VALUES (:PartName, :Quantity);
ENDIF;
END
Execute the procedure with different parameters. The first execution adds a row to the
LargeOrders table.
EXECUTE PROCEDURE Reorder ('Widget', 1500)
The second execution adds a row to the SmallOrders table.
EXECUTE PROCEDURE Reorder ('Widget', 15)