|
|
The BEGIN statement is a compound statement and defines a group
of statements within a procedure.
Procedures only
BEGIN [Statement;][...] END;
- Statement
is the statement or statements between the begin and end of the
statement.
Anyone can use the BEGIN statement.
CREATE PROCEDURE PurchDB.DiscountPart(PartNumber CHAR(16))
AS BEGIN
DECLARE SalesPrice DECIMAL(6,2);
SELECT SalesPrice INTO :SalesPrice
FROM PurchDB.Parts
WHERE PartNumber = :PartNumber;
IF ::sqlcode = 0 THEN
IF :SalesPrice > 100. THEN
BEGIN
:SalesPrice = :SalesPrice*.80;
INSERT INTO PurchDB.Discounts
VALUES (:PartNumber, :SalesPrice);
END
ENDIF;
ENDIF;
END;
|