Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group