shlogg · Early preview
Super Kai (Kazuya Ito) @superkai_kazuya

DO Statement In PostgreSQL: A Beginner's Guide

DO statement in PostgreSQL: atomic, supports PL/pgSQL language, can have DECLARE clause, SELECT INTO, PERFORM, EXECUTE statements, but not RETURN NEXT or QUERY.

Buy Me a Coffee☕

  
  
  DO statement:

can have zero or more queries with BEGIN ... END statement. *Be careful, BEGIN ... END clause is not transaction.
can have DECLARE clause. *My post explains how to declare local variables in DECLARE clause.
can have SELECT INTO statement.
cannot have RETURN NEXT and RETURN QUERY statement.
can have PERFORM statement.
can have EXECUTE. *My post explains how to use EXECUTE statement in a funcition.
can have RETURN statement without a value which is RETURN;.
cannot have RETURN statement with a value e.g. RETURN 2; otherwise there is the error.
cannot have...