Re: conditionally terminate psql script

Поиск
Список
Период
Сортировка
От Torsten Förtsch
Тема Re: conditionally terminate psql script
Дата
Msg-id CAKkG4_myzqwmHOcMRkBeJnR3HeMkbAo-u9E3AMCUSi+2Mx9CXQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: conditionally terminate psql script  (hamann.w@t-online.de)
Список pgsql-general
On Mon, Dec 17, 2018 at 2:07 PM <hamann.w@t-online.de> wrote:
many thanks -- too bad I am still using 9.3


not sure if it has been mentioned in the thread so far. But according to the docs, 9.3 psql does support the \gset command. So you should be able to do something like this:

select case when exists (select 1 from pg_namespace where nspname='tf')
            then '\echo schema tf exists \\ \q'
            else '\echo schema does not exist -- creating ...'
       end as cmd\gset
:cmd

create schema tf;
create table tf.i(i int);

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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: conditionally terminate psql script
Следующее
От: Condor
Дата:
Сообщение: Re: Format an Update with calculation