Firebird Documentation IndexFirebird 2.5 Language Ref. UpdatePSQL statements → Subqueries as PSQL expressions
Firebird Home Firebird Home Prev: PLAN allowed in trigger codeFirebird Documentation IndexUp: PSQL statementsNext: UDFs callable as void functions

Subqueries as PSQL expressions

Changed in: 2.5

Description: Previously, subqueries could not be used as value expressions in PSQL, even if they returned a single value. This made it necessary to use SELECT ... INTO, often assigning the result to a variable that wouldn't have been necessary otherwise. Firebird 2.5 and up support the direct use of scalar subqueries as if they were simple value expressions.

Examples: 

Constructions like the following are now valid PSQL:

var = (select ... from ...);

if ((select ... from ...) = 1) then ...

if (1 = any (select ... from ...)) then ...

if (1 in (select ... from ...)) then ...

Of course, in the first two examples you have to be sure that the SELECT doesn't return multiple rows!

Prev: PLAN allowed in trigger codeFirebird Documentation IndexUp: PSQL statementsNext: UDFs callable as void functions
Firebird Documentation IndexFirebird 2.5 Language Ref. UpdatePSQL statements → Subqueries as PSQL expressions