Re: Question about catching exception - Mailing list pgsql-general

From tv@fuzzy.cz
Subject Re: Question about catching exception
Date
Msg-id decfe71cc7af426aa9d0a4e80559a354.squirrel@sq.gransy.com
Whole thread Raw
In response to Re: Question about catching exception  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general
> Hello
>
> you have to parse a sqlerrm variable

That's one way to do that. Another - more complex but more correct in many
cases is using two separate blocks.

BEGIN
   ... do stuff involving constraint A
EXCEPTION
   WHEN unique_violation THEN ...
END;

BEGIN
   ... do stuff involving constraint B
EXCEPTION
   WHEN unique_violation THEN ...
END;

But that's not possible if there are two unique constraints involved in a
single SQL statement (e.g. inserting into a table with two unique
constraints).

regards
Tomas


pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Question about catching exception
Next
From: c k
Date:
Subject: Re: plpyhton