dbTalk Databases Forums  

using external .sql files from shell script ?

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss using external .sql files from shell script ? in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Francois PUSSAULT
 
Posts: n/a

Default using external .sql files from shell script ? - 01-23-2004 , 04:09 AM






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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.