###Option 1: Let Postgres calculate and set new variables with \gset
Option 1: Let Postgres calculate and set new variables with \gset
The manual about \gset
:The manual about \gset
:
###Option 2: Function with dynamic SQL for repeated use
Option 2: Function with dynamic SQL for repeated use
You could use a DO
statement, but (the manual againthe manual again):
We need dynamic SQL with EXECUTE
. The manual about Variable SubstitutionVariable Substitution: