The Procedure Body

From InterBase
Jump to: navigation, search

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 BEGIN and 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.
  • SELECT statements, to retrieve column values. SELECT statements must have an INTO clause as the last clause.
  • Control-flow statements, such as FOR SELECT DO, IF THEN, and WHILE DO, to perform conditional or looping tasks.
  • EXECUTE PROCEDURE statements, to invoke other procedures. Recursion is allowed.
  • Comments to annotate procedure code.
  • Exception statements, to return error messages to applications, and WHEN statements to handle specific error conditions.
  • SUSPEND and EXIT statements, that return control—and return values of output parameters—to the calling application.

Topics

Advance To: