Re: Trigger disactivation and SELECT WAITING - Mailing list pgsql-general

From Janning Vygen
Subject Re: Trigger disactivation and SELECT WAITING
Date
Msg-id 200507271001.24012.vygen@gmx.de
Whole thread Raw
In response to Re: Trigger disactivation and SELECT WAITING  ("Philippe Lang" <philippe.lang@attiksystem.ch>)
List pgsql-general
Am Mittwoch, 27. Juli 2005 09:47 schrieb Philippe Lang:
> Thanks Tom, thanks Janning,
>
> I found triggers very convenient to do different tasks in the database, and
> these tasks go far beyond what we can do in rules, Janning.

Right. There are some things that can't be done with rules.

> When a line is being inserted in an order, the insert trigger automatically
> inserts data in a subtable of the order line, for example. In this
> subtable, there are informations regarding the "planning" of the order.
> People can use the GUI to populate the order, but things won't break if the
> user opens the database table directly, which can happen sometimes. Without
> the trigger, an "insert function click" would have to be used each time an
> order line is being added, and this is not that effective from a
> user-experience point of view, I think. Or would require a lot a
> client-coding.

As far as i understand your example it can be done with rules, too.

> Now the use of a trigger has a drawback: when you want to duplicate an
> order, for example. During the duplication function, I would like to
> disable the trigger, in order to make a copy of the order, order lines, and
> order lines subtable data. This is much easier than keeping the trigger,
> and having to delete default data it inserts in the new order.

just a thought: maybe you can insert a column "copyof_id" in your tabel and
mark it if you copy orders. The trigger can check NEW.copyof and quit his
work if it is marked.

With rules there is a nice advantage when copying: rules are not invoked by
COPY command (but sometimes it is a disadvantage if you need the rule
invocation)

kind regards
janning

pgsql-general by date:

Previous
From: "Philippe Lang"
Date:
Subject: Re: Trigger disactivation and SELECT WAITING
Next
From: Richard Huxton
Date:
Subject: Re: Postgresql with max_connections=4096