Re: Trigger disactivation and SELECT WAITING

From: Janning Vygen <vygen(at)gmx(dot)de>
To: pgsql-general(at)postgresql(dot)org
Cc: "Philippe Lang" <philippe(dot)lang(at)attiksystem(dot)ch>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Trigger disactivation and SELECT WAITING
Date: 2005-07-27 08:01:23
Message-ID: 200507271001.24012.vygen@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message denis 2005-07-27 08:22:48 Re: Postgresql with max_connections=4096
Previous Message Richard Huxton 2005-07-27 07:52:52 Re: Postgresql with max_connections=4096