Skip site navigation (1) Skip section navigation (2)

Re: Question about catching exception

From: tv(at)fuzzy(dot)cz
To: "A B" <gentosaker(at)gmail(dot)com>
Cc: "postgresql Forums" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question about catching exception
Date: 2010-11-26 10:04:03
Message-ID: decfe71cc7af426aa9d0a4e80559a354.squirrel@sq.gransy.com (view raw or flat)
Thread:
Lists: 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


In response to

pgsql-general by date

Next:From: c kDate: 2010-11-26 11:58:52
Subject: Re: [GENERAL] plpyhton
Previous:From: Pavel StehuleDate: 2010-11-26 09:52:48
Subject: Re: Question about catching exception

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group