Re: Disabling triggers in a transaction

From: "Net Virtual Mailing Lists" <mailinglists(at)net-virtual(dot)com>
To: "Pgsql General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Disabling triggers in a transaction
Date: 2005-03-09 06:08:41
Message-ID: 20050309060841.19330@mail.net-virtual.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>It is the only known way to control triggers though it isn't regularly
>tested by the developers.

I think I've come up with another way.. I posted this recently, but did
not get any feedback on it so I'm not sure how dumb it is... It is
working really great for me though....

All I did was added an extra column to my table (I called it
"batch_process"). Then in
the trigger do something like (in whichever function you are calling):

IF NEW.batch_update IS NOT NULL AND NEW.batch_update = ''t'' THEN
NEW.batch_process := NULL;
RETURN NULL;
END IF;
.. whatever the rest of transaction is

Then when doing an insert, just:

INSERT INTO table (..., batch_process) VALUES (..., 't') when you want the
trigger not to fire...

Or an update:

UPDATE TABLE table SET ...., batch_process = 't' ....

I'm not sure sure how to make it work on a function called from a delete
trigger though.. ;-(

- Greg

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-03-09 06:13:14 Re: PostgreSQL still for Linux only?
Previous Message Uwe C. Schroeder 2005-03-09 06:07:22 Re: PostgreSQL still for Linux only?