Search Postgresql Archives

Re: After Update Triggers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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.

OK, now I understand.

> I didn't include the after insert trigger as there can't be a trigger
> until the ip_op_equipment is updated.

Please post both triggers and prefferably a small testcase - for example
seveal SQL commands (INSERTs / UPDATEs) demonstrating a failure.

I don't understand what do you mean by "there can't be a trigger until
the ip_op_equipment is updated". Well, by the time the AFTER UPDATE
trigger is fired, the update is already done (that's the AFTER keyword),
but I don't understand on what table is the trigger defined etc.

> BTW what is TG_OP that you referred to?

That's one of the variables defined by PL/pgSQL in each trigger. For
example this one means 'TRIGGERING OPERATION' - a trigger can be defined
for several operations simultaneously (AFTER INSERT OR UPDATE OR
DELETE), and in the body you can do something like

  IF TG_OP = 'INSERT' THEN
    ...
  ELSIF TG_OP = 'UPDATE' THEN
    ...
  ELSE
    ...
  END IF;

There are several other useful variables - see the this

  http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html

Tomas


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux