I am looking for some more suggestions here on ways to use
variables in sql scripts to be run on postgresql
We have some Sybase reports that needs to be run against a
postgresql database using sql scripts.
For Sybase they set variables using the declare command for
Declare id int (just an example, not sure about the
Then they refer to this same variable many times in more
than one query within this script.
From what I understand, the guys have a problem due to these
variable declarations not working. They did some investigations and they
stated that they found the possibility of using temporary tables to put the
variables in, however the temp table is only valid for the first transaction
so they are unable to use the variable a second time.
I did some googling as well and found something I tested using
a simple method:
- I created an sql script to set the variable Name DB
o \set DB <dbname>
o \c :DB
- I connected to postgresql using the postgres database and ran the
sql script which seemed to work fine as it then connected me to the
However will this method work with the above situation as well or are there
other ways of doing this?
pgsql-novice by date
|Next:||From: Machiel Richards||Date: 2010-06-09 11:48:21|
|Subject: Additional info on request: Variables in SQL scripts|
|Previous:||From: firstname.lastname@example.org||Date: 2010-06-09 10:37:05|
|Subject: problem with variable|