Have you explored the possibility that the trigger is doing what it is 
supposed to. I would investigate the procedure that updates the 
ip_op_equipment field. Make sure that it is not updating all the rows each 
time and thereby firing your trigger for each update. TG_OP is a variable 
available to trigger functions. It identifies what operation is being done to 
the row i.e. INSERT,UPDATE,DELETE. It is referenced in the pl/pgsql section 
of the manual.
On Friday 17 November 2006 03:49 pm, Bob Pawley wrote:
> I am attempting to distribute the fluid from the process table to its own
> table (pipe or equipment) depending on whether the fluid is classified as
> op, ip or eq.
>
> I didn't include the after insert trigger as there can't be a trigger until
> the ip_op_equipment is updated.
>
> BTW what is TG_OP that you referred to?
>
> Bob
>
> ----- Original Message -----
> From: "Tomas Vondra" <[EMAIL PROTECTED]>
> To: <pgsql-general@postgresql.org>
> Sent: Friday, November 17, 2006 3:34 PM
> Subject: Re: [GENERAL] After Update Triggers
>
> >> When I trigger 'after insert' the function doesn't work because the
> >> ip_op_equipment condition is an update. When I manually enter directley
> >> into the table this trigger works fine when both the fluid and
> >> ip_op_equipment are entered as one entry.
> >>
> >> When I trigger 'after update' every row in the Processes table is
> >> inserted into the other tables depending on the conditionals. I end up
> >> with multiple inserts of the same information.
> >>
> >> Is it possible to create a trigger that inserts only one row for each
> >> entry?
> >
> > Hello,
> >
> > I've read the whole message several times and I have to admit I still
> > don't understand what are you trying to do or what is going wrong.
> >
> > I'm not sure what do you mean by 'when I trigger after insert' - the
> > trigger is defined as AFTER UPDATE so naturally it does not fire in case
> > of an INSERT.
> >
> > Anyway the point is you can define the trigger as AFTER INSERT OR UPDATE
> > and use TG_OP variable, or maybe define several triggers - one for the
> > UPDATE, one for the INSERT.
> >
> > Tomas
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: Have you checked our extensive FAQ?
> >
> >               http://www.postgresql.org/docs/faq
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq

-- 
Adrian Klaver   
[EMAIL PROTECTED]

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

Reply via email to