using external .sql files from shell script ?

Поиск
Список
Период
Сортировка
От Francois PUSSAULT
Тема using external .sql files from shell script ?
Дата
Msg-id OFE55DBE39.3CA944D6-ONC1256E24.0037A71B-41256E24.00372FC3@atofina.com
обсуждение исходный текст
Список 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

В списке pgsql-novice по дате отправления:

Предыдущее
От: Christian Poecher
Дата:
Сообщение: Problem with initdb. Locale?
Следующее
От: Aarni Ruuhimäki
Дата:
Сообщение: 7.4.1 template1