Use variable set by psql meta-command inside of DO block

Answer DO expects a string literal with plpgsql code. Symbols are not substituted inside strings in psql. You could concatenate the whole string into a psql variable and then execute it. How to concatenate psql variables? Pretty multi-line format is not possible, because (per documentation): But in any case, the arguments of a meta-command cannot … Read more

Storing database connection in a session variable [duplicate]

You can’t store database connections or result sets in the session, since those are resources, and: Some types of data can not be serialized thus stored in sessions. It includes resource variables or objects with circular references (i.e. objects which passes a reference to itself to another object). http://php.net/manual/en/intro.session.php You can extract a result set … Read more