From: | "Machiel Richards" <machielr(at)rdc(dot)co(dot)za> |
---|---|
To: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Variables in SQL scripts |
Date: | 2010-06-09 11:38:32 |
Message-ID: | 008e01cb07c8$4cc56690$e65033b0$@co.za |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
HI all
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
instance :
Declare id int (just an example, not sure about the
syntax)
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
database.
However will this method work with the above situation as well or are there
other ways of doing this?
Regards
Machiel
From | Date | Subject | |
---|---|---|---|
Next Message | Machiel Richards | 2010-06-09 11:48:21 | Additional info on request: Variables in SQL scripts |
Previous Message | coviolo@libero.it | 2010-06-09 10:37:05 | problem with variable |