Re: Stop execution without ERROR

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Stop execution without ERROR
Date: 2013-10-16 06:32:41
Message-ID: 20131016063241.GA4638@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Oct 16, 2013 at 12:04:53PM +1100, James Sewell wrote:

> Let's say I'm running the following SQL script via psql -f
>
> BEGIN
> \set ON_ERROR_STOP
> SELECT myFunction();
> CREATE TABLE x(id int);
> END;
>
> Is there anything I can do in myFunction which will:
>
> a) Stop execution of the script so that x will not be created
> b) Not throw an error (return value of 0, no ERROR in output)
>
> I am currently using an EXCEPTION, which satisfies a, but not b.

Any reason you aren't conditionally CREATEing TABLE inside myFunction() ?

Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2013-10-16 07:55:21 Re: Invalid Page Header Error
Previous Message David Johnston 2013-10-16 01:28:10 Re: Stop execution without ERROR