From: Bart Degryse <Bart.Degryse@indicator.be>
To: pgsql-sql@postgresql.org
Subject: Re: trap for any exception
Date: Fri, 16 Nov 2007 08:56:40 +0100
Message-ID: <473D5B47.A3DD.0030.0@indicator.be> (raw)
In-Reply-To: <20071115103448.S32121@megazone.bigpanda.com>
References: <fhhihd$1h5j$1@news.hub.org>
<fhhits$1ico$1@news.hub.org>
<20071115103448.S32121@megazone.bigpanda.com>
I think you should carefully read what the manual tells about PL/pgSQL (http://www.postgresql.org/docs/8.2/static/plpgsql.html) and especially about Trapping Errors (http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING).
>>> Stephan Szabo <sszabo@megazone.bigpanda.com> 2007-11-15 19:36 >>>
On Thu, 15 Nov 2007, Sabin Coanda wrote:
> >
> > I read 37.7.5. Trapping Errors, but the syntax requires to write
> > explicitly the exception condition, and not a generic one.
> >
> > Is it possible to build a generic trap or do you know a workaround for
> > that ?
> >
> Sorry, I found the OTHERS condition that trap any error.
>
> But the question still remains to find how could I interpret it and found
> the error code and message ?
I think you'll want to look at SQLSTATE and SQLERRM inside the exception
handler.
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org ( http://archives.postgresql.org/ )
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: Bart.Degryse@indicator.be
Subject: Re: trap for any exception
In-Reply-To: <473D5B47.A3DD.0030.0@indicator.be>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox