[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    Re: [SQL] trap for any exception
From:       "Bart Degryse" <Bart.Degryse () indicator ! be>
Date:       2007-11-16 7:56:40
Message-ID: 473D5B47.A3DD.0030.0 () indicator ! be
[Download RAW message or body]

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/ )


[Attachment #3 (text/html)]

<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
<META content="MSHTML 6.00.2800.1264" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma">
<DIV>I think you should carefully read what the manual&nbsp;tells about&nbsp;PL/pgSQL \
(<A href="http://www.postgresql.org/docs/8.2/static/plpgsql.html">http://www.postgresql.org/docs/8.2/static/plpgsql.html</A>) \
and especially about Trapping Errors (<A \
href="http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQ \
L-ERROR-TRAPPING">http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING</A>). \
</DIV> <DIV><BR>&gt;&gt;&gt; Stephan Szabo &lt;sszabo@megazone.bigpanda.com&gt; \
2007-11-15 19:36 &gt;&gt;&gt;<BR>On Thu, 15 Nov 2007, Sabin Coanda wrote:<BR><BR>&gt; \
&gt;<BR>&gt; &gt; I read 37.7.5. Trapping Errors, but the syntax requires to \
write<BR>&gt; &gt; explicitly the exception condition, and not a generic one.<BR>&gt; \
&gt;<BR>&gt; &gt; Is it possible to build a generic trap or do you know a workaround \
for<BR>&gt; &gt; that ?<BR>&gt; &gt;<BR>&gt; Sorry, I found the OTHERS condition that \
trap any error.<BR>&gt;<BR>&gt; But the question still remains to find how could I \
interpret it and found<BR>&gt; the error code and message ?<BR><BR>I think you'll \
want to look at SQLSTATE and SQLERRM inside the \
exception<BR>handler.<BR><BR>---------------------------(end of \
broadcast)---------------------------<BR>TIP 4: Have you searched our list \
archives?<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<A href="http://archives.postgresql.org/">http://archives.postgresql.org</A><BR></DIV></BODY></HTML>




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic