Re: psql sqlstate return code access

From: Luca Ferrari <fluca1978(at)infinito(dot)it>
To: "Little, Doug C" <Doug(dot)Little(at)vend(dot)frb(dot)org>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: psql sqlstate return code access
Date: 2015-03-16 17:23:37
Message-ID: CAKoxK+7jtk7QspcB0ZS_g_V00eMrrsGFXK-PR7uxu+D=2vYOoQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

On Mon, Mar 16, 2015 at 4:23 PM, Little, Doug C
<Doug(dot)Little(at)vend(dot)frb(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Brown 2015-03-16 18:27:39 Postgresql BDR(Bi-Directional Replication) Latency Monitoring
Previous Message Rob Richardson 2015-03-16 16:28:32 Re: Update using non-existent fields does not throw an error

Browse pgsql-novice by date

  From Date Subject
Next Message Romain Billon-Grand 2015-03-17 08:06:35 Keeping track of updates/performances
Previous Message Little, Doug C 2015-03-16 15:23:04 psql sqlstate return code access