pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
trap for any exception
6+ messages / 3 participants
[nested] [flat]

* trap for any exception
@ 2007-11-15 13:45 Sabin Coanda <sabin.coanda@deuromedia.ro>
  2007-11-15 13:52 ` Re: trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
  2007-11-15 15:35 ` Re: trap for any exception Stephan Szabo <sszabo@megazone.bigpanda.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Sabin Coanda @ 2007-11-15 13:45 UTC (permalink / raw)
  To: pgsql-sql

Hi there,

I'd like to build a PL/pgSQL function which is able to generic trap any 
error, and interpret it.

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 
?

TIA,
Sabin 





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: trap for any exception
  2007-11-15 13:45 trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
@ 2007-11-15 13:52 ` Sabin Coanda <sabin.coanda@deuromedia.ro>
  2007-11-15 13:54   ` Re: trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
  2007-11-15 18:36   ` Re: trap for any exception Stephan Szabo <sszabo@megazone.bigpanda.com>
  1 sibling, 2 replies; 6+ messages in thread

From: Sabin Coanda @ 2007-11-15 13:52 UTC (permalink / raw)
  To: pgsql-sql

>
> 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 ?

Sabin 





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: trap for any exception
  2007-11-15 13:45 trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
  2007-11-15 13:52 ` Re: trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
@ 2007-11-15 13:54   ` Sabin Coanda <sabin.coanda@deuromedia.ro>
  1 sibling, 0 replies; 6+ messages in thread

From: Sabin Coanda @ 2007-11-15 13:54 UTC (permalink / raw)
  To: pgsql-sql

That's ok, I found SQLSTATE and SQLERRM. 





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: trap for any exception
  2007-11-15 13:45 trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
  2007-11-15 13:52 ` Re: trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
@ 2007-11-15 18:36   ` Stephan Szabo <sszabo@megazone.bigpanda.com>
  2007-11-16 07:56     ` Re: trap for any exception Bart Degryse <Bart.Degryse@indicator.be>
  1 sibling, 1 reply; 6+ messages in thread

From: Stephan Szabo @ 2007-11-15 18:36 UTC (permalink / raw)
  To: Sabin Coanda <sabin.coanda@deuromedia.ro>; +Cc: pgsql-sql

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.



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: trap for any exception
  2007-11-15 13:45 trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
  2007-11-15 13:52 ` Re: trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
  2007-11-15 18:36   ` Re: trap for any exception Stephan Szabo <sszabo@megazone.bigpanda.com>
@ 2007-11-16 07:56     ` Bart Degryse <Bart.Degryse@indicator.be>
  0 siblings, 0 replies; 6+ messages in thread

From: Bart Degryse @ 2007-11-16 07:56 UTC (permalink / raw)
  To: 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@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/ )

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: trap for any exception
  2007-11-15 13:45 trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
@ 2007-11-15 15:35 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Stephan Szabo @ 2007-11-15 15:35 UTC (permalink / raw)
  To: Sabin Coanda <sabin.coanda@deuromedia.ro>; +Cc: pgsql-sql

On Thu, 15 Nov 2007, Sabin Coanda wrote:

> Hi there,
>
> I'd like to build a PL/pgSQL function which is able to generic trap any
> error, and interpret it.
>
> 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
> ?

Won't OTHERS catch most of what you want?



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2007-11-16 07:56 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-15 13:45 trap for any exception Sabin Coanda <sabin.coanda@deuromedia.ro>
2007-11-15 13:52 ` Sabin Coanda <sabin.coanda@deuromedia.ro>
2007-11-15 13:54   ` Sabin Coanda <sabin.coanda@deuromedia.ro>
2007-11-15 18:36   ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2007-11-16 07:56     ` Bart Degryse <Bart.Degryse@indicator.be>
2007-11-15 15:35 ` Stephan Szabo <sszabo@megazone.bigpanda.com>

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