Het volledige antwoord staat in de officiële PostgreSQL-documentatie, maar hier is de praktische truc.
Met de anonieme codeblok-functie die in PG 9.0 werd geïntroduceerd (zie https://www.postgresql.org/docs/9.1/static/sql-do.html) krijg je echte variabelen:
DO $$ DECLARE v_List TEXT; BEGIN v_List := 'foobar' ; SELECT * FROM dbo.PubLists WHERE Name = v_List; -- ... END $$; Je kunt ook de id vastleggen van de rij die je net hebt ingevoegd:
DO $$ DECLARE lastid bigint; BEGIN INSERT INTO test (name) VALUES ('Test Name') RETURNING id INTO lastid; SELECT * FROM test WHERE id = lastid; END $$;