Skip to the content.

Postgres anonymous code blocks

Example:

DO $$
BEGIN
    UPDATE tmpx SET val = '{}' WHERE id = 40;
    PERFORM 'SELECT 1'; -- it just returns text
    PERFORM GetAllFromVmIcons();
    PERFORM * from vms;
    IF (TRUE) THEN BEGIN END; END IF;
    RAISE NOTICE 'a';
END;
$$ LANGUAGE plpgsql;