Re: psql sqlstate return code access - Mailing list pgsql-general

From Luca Ferrari
Subject Re: psql sqlstate return code access
Date
Msg-id CAKoxK+7jtk7QspcB0ZS_g_V00eMrrsGFXK-PR7uxu+D=2vYOoQ@mail.gmail.com
Whole thread Raw
In response to psql sqlstate return code access  ("Little, Doug C" <Doug.Little@vend.frb.org>)
List pgsql-general
On Mon, Mar 16, 2015 at 4:23 PM, Little, Doug C
<Doug.Little@vend.frb.org> wrote:
> insert into x select … from y;
>
>
>
> insert into log(message, code,timestamp)  values('insert into
> x',:SQLSTATE,now());
>
>

I'm pretty sure you have to wrap it into a plpgsql function:
http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html
Moreover, if the command executes correctly you would have no
exception and sql state will be 0.

Hope this helps.

Luca


pgsql-general by date:

Previous
From: Rob Richardson
Date:
Subject: Re: Update using non-existent fields does not throw an error
Next
From: Bill Brown
Date:
Subject: Postgresql BDR(Bi-Directional Replication) Latency Monitoring