![]() |
ALLBASE/SQL Reference Manual
> Chapter 11 SQL Statements E - RIF |
|||||||||||||||||||||||
|
ScopeProcedures only SQL SyntaxIF Condition THEN [Statement;[...]] [ELSEIF Condition THEN [Statement; [...]]] [ELSE [Statement; [...]]] ENDIF; Parameters
Description
AuthorizationAnyone can use the IF statement. ExampleCreate 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)
|