Re: Passing parameters into an in-line psql invocation - Mailing list pgsql-general

From Bosco Rama
Subject Re: Passing parameters into an in-line psql invocation
Date
Msg-id 4DE7E456.1050700@boscorama.com
Whole thread Raw
In response to Passing parameters into an in-line psql invocation  ("Gauthier, Dave" <dave.gauthier@intel.com>)
List pgsql-general
Gauthier, Dave wrote:
>
> 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.

You may want to use the --set or --variable options of psql and then
reference the variable name in thesqlscript.

So the psql becomes:
   psql --set 'var=foo' -c '\i thesqlscript'

and then in thesqlscript:
   update table set column = :var;

HTH

Bosco.

pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Passing parameters into an in-line psql invocation
Next
From: Bosco Rama
Date:
Subject: Re: Postgres 8.3.5 - ECPG and the use of descriptors and cursors in multi-threaded programs