Firebird 2.5 Language ReferenceFirebird 2.5 Language ReferenceProcedural SQL (PSQL) Statements → Stored Functions
Firebird Firebird Prev: Stored ProceduresFirebird 2.5 Language ReferenceUp: Procedural SQL (PSQL) StatementsNext: PSQL Blocks

Stored Functions

Stored PSQL scalar functions are not supported in this version but they are coming in Firebird 3. In Firebird 2.5 and below, you can instead write a selectable stored procedure that returns a scalar result and SELECT it from your DML query or subquery.

Example: 

SELECT
  PSQL_FUNC(T.col1, T.col2) AS col3,
  col3
FROM T
        

can be replaced with

SELECT
  (SELECT output_column FROM  PSQL_PROC(T.col1)) AS col3,
  col2
FROM T
        

or

SELECT
  output_column AS col3,
  col2,
FROM T
LEFT JOIN PSQL_PROC(T.col1)
        

Prev: Stored ProceduresFirebird 2.5 Language ReferenceUp: Procedural SQL (PSQL) StatementsNext: PSQL Blocks
Firebird 2.5 Language ReferenceFirebird 2.5 Language ReferenceProcedural SQL (PSQL) Statements → Stored Functions