Re: conditionally terminate psql script

From: Steven Lembark <lembark(at)wrkhors(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Cc: lembark(at)wrkhors(dot)com
Subject: Re: conditionally terminate psql script
Date: 2018-12-18 21:42:14
Message-ID: 20181218154214.06bd0904.lembark@wrkhors.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 17 Dec 2018 13:42:14 +0100
Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:

> you need psql from PostgreSQL 10 and higher
>
> there is a \if statement

Q: What is the "abort cycle command"?

e.g.,

select count(1) < 1 as "lacks_rows";
from foobar
where blah blah
\gset

\if :lacks_rows

\echo foobar lacks rows to process.
\echo goodnight :-)

????????? <--- what goes here to stop execution?

\endif

The point is that adding many levels of if-block logic is becomes
difficult to maintain. It would be nice to stop execution without
having to nest everything one level deeper.

--
Steven Lembark 3920 10th Ave South
Workhorse Computing Birmingham, AL 35222
lembark(at)wrkhors(dot)com +1 888 359 3508

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-12-18 21:47:46 Re: conditionally terminate psql script
Previous Message Tom Lane 2018-12-18 17:53:15 Re: Problem with text search in Postgresql 10