Re: trap for any exception

From: "Bart Degryse" <Bart(dot)Degryse(at)indicator(dot)be>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: trap for any exception
Date: 2007-11-16 07:56:40
Message-ID: 473D5B47.A3DD.0030.0@indicator.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)megazone(dot)bigpanda(dot)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/ )

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jean-David Beyer 2007-11-16 12:54:11 Re: Is there anything special about pg_dump's compression?
Previous Message Tom Lane 2007-11-16 05:29:31 Re: Is there anything special about pg_dump's compression?