Re: conditionally terminate psql script

From: hamann(dot)w(at)t-online(dot)de
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: conditionally terminate psql script
Date: 2018-12-17 14:31:03
Message-ID: wolfgang-1181217153103.A0720644@noten19.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

many thanks, I will give it a try tomorrow

Best regards
Wolfgang

>> >> On 17.12.2018 16:07, hamann(dot)w(at)t-online(dot)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
>> >> >>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vijaykumar Jain 2018-12-17 14:32:42 Re: [External] Re: simple query on why a merge join plan got selected
Previous Message Pavel Luzanov 2018-12-17 13:30:25 Re: conditionally terminate psql script