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

Re: Trigger AFTER UPDATE OR INSERT

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: yogesh <yogesh(dot)arora(dot)daffodil(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Trigger AFTER UPDATE OR INSERT
Date: 2007-10-19 18:05:37
Message-ID: dcc563d10710191105k244a5fecsb59718f9be6a322f@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
On 10/19/07, yogesh <yogesh(dot)arora(dot)daffodil(at)gmail(dot)com> wrote:
> Hello frnds,
>  I have a trigger on a table with After UPDATE OR INSERT ..that insert
> a record in an another table..........If the Trigger Fire Correctly
> the row is inserted or updated in the database as the case is. But if
> it is not fire correctly then the table is also not updated on which
> the trigger is..............
>
> Is it the right .................?  if yes......How to insert the
> record in the table if the trigger is failed.

Yes, it's right.  Triggers are part of a transaction (or run their
own) so if the trigger fails, so does the transaction.

If you really need to have something insert rather or not the
transaction succeeds, you can either use savepoints so that you can
roll back to before the error then insert the row anyway, or use
dblink to connect to the db through another backend and commit your
data that way.

You might want to give more info on exactly what you're trying to do
so the folks on the list can make better informed recommendations.

In response to

Responses

pgsql-admin by date

Next:From: Scott MarloweDate: 2007-10-19 18:30:10
Subject: Re: Cluster/Replication
Previous:From: Joshua D. DrakeDate: 2007-10-19 17:06:26
Subject: Re: Cluster/Replication

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