Re: conditionally terminate psql script - Mailing list pgsql-general

From Steven Lembark
Subject Re: conditionally terminate psql script
Date
Msg-id 20181218154214.06bd0904.lembark@wrkhors.com
Whole thread Raw
In response to Re: conditionally terminate psql script  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: conditionally terminate psql script
List pgsql-general
On Mon, 17 Dec 2018 13:42:14 +0100
Pavel Stehule <pavel.stehule@gmail.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@wrkhors.com                                    +1 888 359 3508


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Problem with text search in Postgresql 10
Next
From: "David G. Johnston"
Date:
Subject: Re: conditionally terminate psql script