The Procedure Body
Go Up to Creating Procedures
Everything following the AS keyword in the
CREATE PROCEDURE statement forms the procedure body. The body consists of an optional list of local variable declarations followed by a block of statements.
A block is composed of statements in the InterBase procedure and trigger language, bracketed by
END. A block can itself include other blocks, so that there can be many levels of nesting.
InterBase procedure and trigger language includes all standard InterBase SQL statements except data definition and transaction statements, plus statements unique to procedure and trigger language.
Features of InterBase procedure and trigger language include:
- Assignment statements, to set values of local variables and input/output parameters.
SELECTstatements, to retrieve column values.
SELECTstatements must have an
INTOclause as the last clause.
- Control-flow statements, such as
FOR SELECT … DO,
IF … THEN, and
WHILE … DO, to perform conditional or looping tasks.
EXECUTE PROCEDUREstatements, to invoke other procedures. Recursion is allowed.
- Comments to annotate procedure code.
- Exception statements, to return error messages to applications, and
WHENstatements to handle specific error conditions.
EXITstatements, that return control—and return values of output parameters—to the calling application.
- BEGIN … END statements
- Using Variables
- Using Assignment Statements
- Using SELECT Statements
- Using FOR SELECT … DO Statements
- Using WHILE … DO Statements
- Using IF … THEN … ELSE Statements
- Using Event Alerters
- Adding Comments
- Creating Nested and Recursive Procedures
- Using SUSPEND, EXIT, and END With Procedures