Re: transaction aborted with error - Mailing list pgsql-general

From jdassen@cistron.nl (J.H.M. Dassen (Ray))
Subject Re: transaction aborted with error
Date
Msg-id slrn9bjvrk.v22.jdassen@odin.cistron-office.nl
Whole thread Raw
In response to transaction aborted with error  (DaVinci <bombadil@wanadoo.es>)
List pgsql-general
DaVinci <bombadil@wanadoo.es> wrote:
> When I am in middle of transaction and there is an error, for example
> caused by trying to insert a tupla with a "not null" value without valor,
> I get error:
>
>     NOTICE: current transaction is aborted, queries ignored until end of
>    transaction block.
>
> I don't like this behaviour, is there any form of avoiding abortion of
> transaction on error?...

Not really. One of the points of having transactions is that a transaction
either succeeds (as a whole), or has no effect (rollback). Triggers can
provide a workaround though.

I ran into this problem with a table which contained log-like information
which should be inserted only once, but wasn't (due to a misconfiguration in
the system generating the logs). I solved it by having a trigger (BEFORE
INSERT OR UPDATE) which RAISEd a NOTICE (so it's clear the workaround
occurs) and returns NULL, causing the insert to be ignored.

HTH,
Ray
--
Where do you want to go today?

Confutatis maledictis, flammis acribus addictis.

pgsql-general by date:

Previous
From: "Tamsin"
Date:
Subject: non-existent user "28"
Next
From: "Daniel Francisco Sachet"
Date:
Subject: