Firebird Documentation Index → Firebird 3.0.6 Release Notes → Procedural SQL (PSQL) → PSQL Sub-routines |
![]() |
![]() |
![]() ![]() ![]() ![]() |
The header of a PSQL module (stored procedure, stored function, trigger, executable block) can now accept sub-procedure and sub-function blocks in the header declarations for use within the body of the module.
Syntax for Declaring a Sub-procedure
DECLARE PROCEDURE <name> [(param1 [, ...])] [RETURNS (param1 [, ...])] AS ...
Syntax for declaring a Sub-function
DECLARE FUNCTION <name> [(param1 [, ...])] RETURNS <type> AS ...
Examples
SET TERM ^; -- -- Sub-function in EXECUTE BLOCK -- EXECUTE BLOCK RETURNS (N INT) AS DECLARE FUNCTION F(X INT) RETURNS INT AS BEGIN RETURN X+1; END BEGIN N = F(5); SUSPEND; END ^ -- -- Sub-function inside a stored function -- CREATE OR ALTER FUNCTION FUNC1 (n1 INTEGER, n2 INTEGER) RETURNS INTEGER AS DECLARE FUNCTION SUBFUNC (n1 INTEGER, n2 INTEGER) RETURNS INTEGER AS BEGIN RETURN n1 + n2; END BEGIN RETURN SUBFUNC(n1, n2); END ^ -- select func1(5, 6) from rdb$database ^
![]() ![]() ![]() ![]() |
Firebird Documentation Index → Firebird 3.0.6 Release Notes → Procedural SQL (PSQL) → PSQL Sub-routines |