pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Trigger AFTER UPDATE OR INSERT
4+ messages / 2 participants
[nested] [flat]

* Trigger AFTER UPDATE OR INSERT
@ 2007-10-19 07:09  yogesh <yogesh.arora.daffodil@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: yogesh @ 2007-10-19 07:09 UTC (permalink / raw)
  To: pgsql-admin

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.


Regards, Yogesh Arora.




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

* Re: Trigger AFTER UPDATE OR INSERT
@ 2007-10-19 18:05  Scott Marlowe <scott.marlowe@gmail.com>
  parent: yogesh <yogesh.arora.daffodil@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Scott Marlowe @ 2007-10-19 18:05 UTC (permalink / raw)
  To: yogesh <yogesh.arora.daffodil@gmail.com>; +Cc: pgsql-admin

On 10/19/07, yogesh <yogesh.arora.daffodil@gmail.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.



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

* Re: Trigger AFTER UPDATE OR INSERT
@ 2007-10-20 06:00  yogesh <yogesh.arora.daffodil@gmail.com>
  parent: Scott Marlowe <scott.marlowe@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: yogesh @ 2007-10-20 06:00 UTC (permalink / raw)
  To: pgsql-admin

On Oct 19, 11:05 pm, scott.marl...@gmail.com ("Scott Marlowe") wrote:
> On 10/19/07, yogesh <yogesh.arora.daffo...@gmail.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.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match


Hello Scott,
Thanks to you....
   you got the right point point what i want to know.......

 are you saying about programming or any other way to done
it........to insert a row even if the Trigger fails or succeeds


Regards,
   Yogesh Arora





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

* Re: Trigger AFTER UPDATE OR INSERT
@ 2007-10-21 14:18  Scott Marlowe <scott.marlowe@gmail.com>
  parent: yogesh <yogesh.arora.daffodil@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Scott Marlowe @ 2007-10-21 14:18 UTC (permalink / raw)
  To: yogesh <yogesh.arora.daffodil@gmail.com>; +Cc: pgsql-admin

On 10/20/07, yogesh <yogesh.arora.daffodil@gmail.com> wrote:
> On Oct 19, 11:05 pm, scott.marl...@gmail.com ("Scott Marlowe") wrote:
> > 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.

> Hello Scott,
> Thanks to you....
>    you got the right point point what i want to know.......
>
>  are you saying about programming or any other way to done
> it........to insert a row even if the Trigger fails or succeeds

Read up on savepoints here:
http://www.postgresql.org/docs/8.2/static/sql-savepoint.html



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


end of thread, other threads:[~2007-10-21 14:18 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-10-19 07:09 Trigger AFTER UPDATE OR INSERT yogesh <yogesh.arora.daffodil@gmail.com>
2007-10-19 18:05 ` Scott Marlowe <scott.marlowe@gmail.com>
2007-10-20 06:00   ` yogesh <yogesh.arora.daffodil@gmail.com>
2007-10-21 14:18     ` Scott Marlowe <scott.marlowe@gmail.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