Re: Perl and psql variables - Mailing list pgsql-novice

From Tom Lane
Subject Re: Perl and psql variables
Date
Msg-id 19055.1146069492@sss.pgh.pa.us
Whole thread Raw
In response to Perl and psql variables  (Mark Campbell <mdc@ucs.co.za>)
Responses Re: Perl and psql variables
List pgsql-novice
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 by date:

Previous
From: Oscar Rodriguez Fonseca
Date:
Subject: Re: How to obtain algebraic sum of equal lines
Next
From: Mark Campbell
Date:
Subject: Re: Perl and psql variables