Re: Perl and psql variables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Campbell <mdc(at)ucs(dot)co(dot)za>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Perl and psql variables
Date: 2006-04-26 16:38:12
Message-ID: 19055.1146069492@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Mark Campbell <mdc(at)ucs(dot)co(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Leonardo Boiko 2006-04-26 19:52:55 Trigger to force fields to lowercase at insert/update
Previous Message Oscar Rodriguez Fonseca 2006-04-26 14:25:55 Re: How to obtain algebraic sum of equal lines