Re: Passing parameters into an in-line psql invocation

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Passing parameters into an in-line psql invocation
Date: 2011-06-02 18:46:49
Message-ID: 4DE7DA99.1010609@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 06/02/11 9:58 AM, Gauthier, Dave wrote:
>
> Hi:
>
> I'd like to pass a parameter into an inline psql call that itself
> calls an sql script, something like...
>
> psql mydb -c "\i thesqlscript foo"
>
> Where"foo" is the value I want to pass in.
>

on the psql command line,
-v name=value
or
--set name=value

then in your script, use :name if you want to use "value" as a sql
identifier and (in 9.x), you can use :'value' if you want to use
'value' as a string literal.

--
john r pierce N 37, W 123
santa cruz ca mid-left coast

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bosco Rama 2011-06-02 19:21:47 Re: Postgres 8.3.5 - ECPG and the use of descriptors and cursors in multi-threaded programs
Previous Message John R Pierce 2011-06-02 16:58:51 Re: Need suggestion