Re: Transaction commit in a trigger function

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Henka <henka(at)cityweb(dot)co(dot)za>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Transaction commit in a trigger function
Date: 2007-05-17 19:03:42
Message-ID: 20070517190342.GO28701@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Henka wrote:

> Is it possible to (somehow) commit a specific statement in a trigger
> function if the function itself is rolled back because of an error (eg, for a
> unique index error)?

No. You can use savepoints (or, in PL/pgSQL functions, EXCEPTION
blocks) to inhibit the uniqueness error from aborting the transaction.
There is an example in the error catching section of the PL/pgSQL docs
about the insert-if-fail-update construct.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hannes Dorbath 2007-05-17 19:04:14 Re: Fault Tolerant Postgresql (two machines, two postmasters, one disk array)
Previous Message ABHANG RANE 2007-05-17 18:49:36 contrib