7.3. 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

  1. SELECT
  2. PSQL_FUNC(T.col1, T.col2) AS col3,
  3. col3
  4. FROM T

can be replaced with:

  1. SELECT
  2. (SELECT output_column FROM PSQL_PROC(T.col1)) AS col3,
  3. col2
  4. FROM T

or

  1. SELECT
  2. output_column AS col3,
  3. col2,
  4. FROM T
  5. LEFT JOIN PSQL_PROC(T.col1)