InterBase Procedure and Trigger Language
Go Up to Creating Triggers
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
. - SQL operators and expressions, including UDFs that are 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 entirely different ways and for different purposes, they both use procedure and trigger language. Both triggers and stored procedures may use any statements in procedure and trigger language, with some exceptions:
- Context variables are unique to triggers.
- Input and output parameters, and the
SUSPEND
andEXIT
statements which return values 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, DECLARE EXTERNAL FUNCTION, and DECLARE FILTER
- Transaction control statements: SET TRANSACTION, COMMIT, ROLLBACK
- Dynamic SQL statements: PREPARE, DESCRIBE, EXECUTE
- CONNECT/DISCONNECT, and sending SQL statements to another database
- GRANT/REVOKE
- SET GENERATOR
- EVENT INIT/WAIT
- BEGIN/END DECLARE SECTION
- BASED ON
- WHENEVER
- DECLARE CURSOR
- OPEN
- FETCH
The following table summarizes the language extensions for triggers:
Statement | Description |
---|---|
|
Defines a block of statements that executes as one. The |
<variable> = <expression> |
Assignment statement which assigns the value of <expression> to local variable, <variable>. |
/* comment_text */ |
Programmer’s comment, where <comment_text> can be any number of lines of text. |
|
Raises the named exception. An exception is a user-defined error, which returns an error message to the calling application unless handled by a |
|
Executes stored procedure, <proc_name>, with the listed input arguments, returning values in the listed output arguments. Input and output arguments must be local variables. |
|
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 ( |
|
New context variable that indicates a new column value in an |
|
Old context variable that indicates a column value before an |
|
Posts the event, <event_name>. |
|
While <condition> is |
|
Error-handling statement. When one of the specified errors occurs, performs <compound_statement>. <error>:
|