Procedure and Trigger Language
Go Up to Creating Procedures
The InterBase procedure and trigger language is a complete programming language for stored procedures and triggers. It includes:
- SQL data manipulation statements:
INSERT,UPDATE,DELETE, and singletonSELECT. Cursors are allowed. - SQL operators and expressions, including UDFs linked with the database server and generators.
- Powerful extensions to SQL, including assignment statements, control-flow statements, context variables, event-posting statements, exceptions, and error-handling statements.
Although stored procedures and triggers are used in different ways and for different purposes, they both use the procedure and trigger language. Both triggers and stored procedures can use any statements in the procedure and trigger language, with some exceptions:
- Context variables are unique to triggers.
- Input and output parameters, and the
SUSPENDandEXITstatements, which return values and are unique to stored procedures.
The stored procedure and trigger language does not include many of the statement types available in DSQL or gpre. The following statement types are not supported in triggers or stored procedures:
- Data definition language statements:
CREATE,ALTER,DROP,DECLAREEXTERNAL FUNCTION, andDECLARE FILTER - Transaction control statements:
SET TRANSACTION,COMMIT,ROLLBACK - Dynamic SQL statements:
PREPARE,DESCRIBE,EXECUTE CONNECT/DISCONNECT, and sending SQL statements to another databaseGRANT/REVOKESET GENERATOREVENT INIT/WAITBEGIN/END DECLARE SECTIONBASED ONWHENEVERDECLARE CURSOROPENFETCH
The following table summarizes the language extensions for stored procedures.
| Statement | Description |
|---|---|
|
|
Defines a block of statements that executes as one; the |
|
<variable> = <expression> |
Assignment statement which assigns the value of <expression> to <variable>, a local variable, input parameter, or output parameter. |
|
/* comment_text */ |
Programmer’s comment, where <comment_text> can be any number of lines of text. |
|
|
Raises the named exception. Exception: A user-defined error that can be handled with |
|
|
Executes stored procedure, <proc_name>, with the input arguments listed following the procedure name, returning values in the output arguments listed following Enables nested procedures and recursion. Input and output parameters must be variables defined within the procedure. |
|
|
Jumps to the final |
|
|
Repeats the statement or block following <select_statement>: a normal |
|
<compound_statement> |
Either a single statement in procedure and trigger language or a block of statements bracketed by |
|
|
Tests <condition> and if it is <condition>: a Boolean expression ( |
|
|
Posts the event, <event_name>. |
|
|
In a Suspends execution of procedure until next Returns output values, if any, to the calling application. Not recommended for executable procedures. |
|
|
While <condition> is |
|
|
Error-handling statement. When one of the specified errors occurs, performs <compound_statement>. <error>:
|