How to assign the result of a query to a variable in PL/pgSQL, the procedural language of PostgreSQL?
I have a function:
CREATE OR REPLACE FUNCTION t
The usual pattern is EXISTS(subselect):
EXISTS(subselect)
BEGIN IF EXISTS(SELECT name FROM test_table t WHERE t.id = x AND t.name = 'test') THEN --- ELSE --- END IF;
This pattern is used in PL/SQL, PL/pgSQL, SQL/PSM, ...