Firebird Documentation IndexFirebird 3.0.6 Release NotesProcedural SQL (PSQL) → PSQL Stored Functions
Firebird Home Firebird Home Prev: Procedural SQL (PSQL)Firebird Documentation IndexUp: Procedural SQL (PSQL)Next: PSQL Sub-routines

PSQL Stored Functions

Dmitry Yemanov

It is now possible to write a scalar function in PSQL and call it just like an internal function.

Syntax for the DDL

  {CREATE [OR ALTER] | ALTER | RECREATE} FUNCTION <name>
  [(param1 [, ...])]
  RETURNS <type>
  AS
  BEGIN
    ...
  END
      

Tip

The CREATE statement is the declaration syntax for PSQL functions, parallel to DECLARE for legacy UDFs.

Example

CREATE FUNCTION F(X INT) RETURNS INT
AS
BEGIN
  RETURN X+1;
END;
SELECT F(5) FROM RDB$DATABASE;
      
Prev: Procedural SQL (PSQL)Firebird Documentation IndexUp: Procedural SQL (PSQL)Next: PSQL Sub-routines
Firebird Documentation IndexFirebird 3.0.6 Release NotesProcedural SQL (PSQL) → PSQL Stored Functions