Re: conditionally terminate psql script

Поиск
Список
Период
Сортировка
От Pavel Luzanov
Тема Re: conditionally terminate psql script
Дата
Msg-id 2c2417d2-9a81-73e7-23d5-a10436e4a2ff@postgrespro.ru
обсуждение исходный текст
Ответ на Re: conditionally terminate psql script  (hamann.w@t-online.de)
Ответы Re: conditionally terminate psql script
Список pgsql-general
On 17.12.2018 16:07, hamann.w@t-online.de wrote:
> Hi, many thanks -- too bad I am still using 9.3

In this case you can try ON_ERROR_STOP psql variable.
Something like this:

\set ON_ERROR_STOP on

do $$
declare
     total bigint;
begin
     select count(*) into total from pg_class where 1=1;
     if total = 0 then
         raise exception 'Nothing found.';
     end if;

     raise notice '% records found.', total;
end;
$$ language plpgsql;

\echo Continue execution...

-----
Pavel Luzanov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company




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

Предыдущее
От: hamann.w@t-online.de
Дата:
Сообщение: Re: conditionally terminate psql script
Следующее
От: hamann.w@t-online.de
Дата:
Сообщение: Re: conditionally terminate psql script