From: | Tomas Vondra <tv(at)fuzzy(dot)cz> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: After Update Triggers |
Date: | 2006-11-18 00:45:24 |
Message-ID: | 455E57A4.6040503@fuzzy.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2006-11-18 01:29:26 | Re: [GENERAL] Allowing SYSDATE to Work |
Previous Message | Jeremy Smith | 2006-11-18 00:42:43 | Re: PostgreSQL: Question about rules |