Re: Passing parameters into an in-line psql invocation

Поиск
Список
Период
Сортировка
От Bosco Rama
Тема Re: Passing parameters into an in-line psql invocation
Дата
Msg-id 4DE7E456.1050700@boscorama.com
обсуждение исходный текст
Ответ на Passing parameters into an in-line psql invocation  ("Gauthier, Dave" <dave.gauthier@intel.com>)
Список 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 по дате отправления:

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: Passing parameters into an in-line psql invocation
Следующее
От: Bosco Rama
Дата:
Сообщение: Re: Postgres 8.3.5 - ECPG and the use of descriptors and cursors in multi-threaded programs