According to the PostgreSQL documentation, there appears to be support for SET CONNECTION.
However, when I try to execute it from the psql prompt, I get
ERROR: unrecognized configuration parameter "connection"
I'm well aware of using \connect but I want to be able to switch databases within the execution of a .sql file.
Is this a bug in PostgreSQL? Or does some flag need to be set to create the parameter?
Best Answer
Converting question comments into an answer
Abelisto:
It seems that you missed a section of the documentation: Chapter 34. ECPG - Embedded SQL in C. The PostgreSQL documentation is not ideal (but IMO it is much better then many others). Hint: to avoid inconveniences look at the page name in the address, for example
plpgsql-declarations.html
is aboutDECLARE
variables in theplpgsql
blocks andsql-declare.html
is aboutDECLARE
cursors in the pure SQL.dezso:
If using
psql
, you still can make use of\c
- especially if it does not require typing a password.