Re: Setting a psql variable from SQL output

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Setting a psql variable from SQL output
Дата
Msg-id CAHyXU0wMFhK=vuhor4xbw96yXuR7YDGiQcipdmiJPofWoqNR5g@mail.gmail.com
обсуждение исходный текст
Ответ на Setting a psql variable from SQL output  (Bobby Dewitt <Bdewitt@appriss.com>)
Ответы Re: Setting a psql variable from SQL output  (Rob Sargent <robjsargent@gmail.com>)
Re: Setting a psql variable from SQL output  (Bobby Dewitt <Bdewitt@appriss.com>)
Список pgsql-general
On Fri, Aug 26, 2011 at 3:01 PM, Bobby Dewitt <Bdewitt@appriss.com> wrote:
> Is there a way to get output from a SQL command or function and have it be
> set to a variable value in psql?  My main goal is to execute a certain
> script depending on the version of the database server (either 8.4 or 9.0).
>  I can dynamically execute a script using the following, but I can't get it
> to set the myscript variable value based on the version of the database:
> \set myscript 'psql_script.sql'
> \i :myscript
> However, I would like to be able to have the script executed like this:
> \set myscript = 'select substring(version() from 12 for 5);'
> \i :myscript
>
> I can obviously select the version into a PL/PGSQL variable, but then I
> can't execute the script from PL/PGSQL.

what's your scripting environment? you're probably better off handling
this from there...

merlin

В списке pgsql-general по дате отправления:

Предыдущее
От: Bobby Dewitt
Дата:
Сообщение: Setting a psql variable from SQL output
Следующее
От: Rob Sargent
Дата:
Сообщение: Re: Setting a psql variable from SQL output