Re: Perl and psql variables

Поиск
Список
Период
Сортировка
От Mark Campbell
Тема Re: Perl and psql variables
Дата
Msg-id 44508C96.2050203@ucs.co.za
обсуждение исходный текст
Ответ на Re: Perl and psql variables  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Thx for the replies

What I found after really reading the man pages of psql is the -v switch

So the following now works for me:

psql -f sql.file -v month=$month

and I have the variable :month in the sql.file

Regards

Mark Campbell


Confidentiality Notice: http://ucs.co.za/conf.html


Tom Lane wrote:
Mark Campbell <mdc@ucs.co.za> writes: 
the perl script generates a variable called $month (which is the current 
month), I then need that month variable passed as a command line line 
parameter to psql. eg psql -f sql.file --variable "month = $month"
then do a SELECT with the variable called :month   
How about something like
(  echo "\set :month = $month"  cat sql.file) | psql
		regards, tom lane 

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Perl and psql variables
Следующее
От: Verena Ruff
Дата:
Сообщение: error handling