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

Re: After insert trigger question

From: Stephane Bortzmeyer <bortzmeyer(at)nic(dot)fr>
To: mmiranda(at)americatel(dot)com(dot)sv
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: After insert trigger question
Date: 2005-04-27 15:24:16
Message-ID: 20050427152416.GB4188@nic.fr (view raw or flat)
Thread:
Lists: pgsql-general
On Wed, Apr 27, 2005 at 08:45:44AM -0600,
 mmiranda(at)americatel(dot)com(dot)sv <mmiranda(at)americatel(dot)com(dot)sv> wrote 
 a message of 21 lines which said:

> I am concerned about how reliable is an before insert trigger, i
> made some computation in my trigger and i want that no matter what
> happens inside the trigger (exceptions, erros, divide by zero, etc)
> , the row must be inserted,

I do not think that pl/pgsql has exception handlers
(http://www.postgresql.org/docs/7.4/interactive/plpgsql-errors-and-messages.html). You
can raise exceptions but not catch them. Could you rewrite your
trigger function with another programming language? In Python, it
would be something like (not tested):

try:
   ... your computations
finally:
   # Insert anyway
   return "OK"

In response to

Responses

pgsql-general by date

Next:From: Ned LillyDate: 2005-04-27 16:04:17
Subject: Re: OpenRPT (was Re: [ANNOUNCE] == PostgreSQL Weekly
Previous:From: Scott MarloweDate: 2005-04-27 15:23:19
Subject: Re: Reduce size of $PGDATA for "demo cdrom"?

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