Re: Make a SQL statement not run trigger

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Make a SQL statement not run trigger
Date: 2007-08-21 22:24:59
Message-ID: fafonr$u84$1@sea.gmane.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Jon Collette wrote on 21.08.2007 23:26:
> Is it possible to run an insert,update, or delete and have it not launch
> a trigger like it normally would?
>
> For example could I set a value
> DONOTRUN = True;
> insert into contacts ....
>
> Where the trigger on contacts would call a function that would have an
> IF statment for that DONOTRUN value?
>
> Or is there just a global variable I could set to disable triggers and
> then reset it? And would that be a per connection variable?

What we have done once, was to include a column in the table for this purpose.
If a special value for the column was provided during UPDATE or INSERT, the
trigger would immediately terminate, not doing any work. Thus the trigger still
"fires" every time, but simply won't do nothing. Not very elegant, but worked
for our environment.

Thomas

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jon Collette 2007-08-21 22:44:33 Re: Make a SQL statement not run trigger
Previous Message Scott Marlowe 2007-08-21 22:07:29 Re: Make a SQL statement not run trigger