From: | "Francois PUSSAULT" <francois(dot)pussault(at)grande-paroisse(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | using external .sql files from shell script ? |
Date: | 2004-01-23 10:09:36 |
Message-ID: | OFE55DBE39.3CA944D6-ONC1256E24.0037A71B-41256E24.00372FC3@atofina.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hello all
#> I hope you can help me. I am a novice to postgreSQL.
#> I'm tying to write a little shellscript/SQL application on unix system.
#> I use a simple shell script that calls some external SQL insructions
file.
#> so I have 2 questions about it
--------------------------------
1) Is there any oracle-SPOOL similar command under psql ?
#> actually I use psql -f foobar.sql
--------------------------------
2) How to use shell scripts variables as parameter to the external .sql
file ?
#> for example currently I must do :
#!/bin/sh
.....
.....
read toto
.....
psql -f $commande.sql $basename -o $commande.log
.....
exit
#> all my .sql files look like :
.....
\set foo '\''`echo $toto`'\''
\set tabl '\''`echo $table`'\''
.....
begin
.....
insert into :tabl values(....,....,....,:foo,....);
.....
end
#> So is this possible to use toto named variable from shell script
without creating foo named variable in .sql script ?
#> Is there a better method to do so ?
-----------------------------
regards
From | Date | Subject | |
---|---|---|---|
Next Message | Aarni Ruuhimäki | 2004-01-23 13:47:44 | 7.4.1 template1 |
Previous Message | Christian Poecher | 2004-01-23 09:01:37 | Problem with initdb. Locale? |