Is there a way to know if trigger is invoked by the code from another trigger

Started by Naoko Reevesover 16 years ago3 messagesgeneral
Jump to latest
#1Naoko Reeves
naoko@lawlogix.com

Could you tell me if there is a way to know if trigger is invoked by the
code from another trigger?

For instance, table A Trigger deletes table B record. While in table B
trigger, I want to know whether this was triggered from table A.

Thank you,

Naoko

#2Erik Jones
ejones@engineyard.com
In reply to: Naoko Reeves (#1)
Re: Is there a way to know if trigger is invoked by the code from another trigger

On Oct 11, 2009, at 10:51 AM, Naoko Reeves wrote:

Could you tell me if there is a way to know if trigger is invoked by
the code from another trigger?
For instance, table A Trigger deletes table B record. While in table
B trigger, I want to know whether this was triggered from table A.

Nothing built in to show you that. You could, however, have your
trigger on table A make an insert or update to a record in some table
that the trigger on table B could then look for.

Erik Jones, Database Administrator
Engine Yard
Support, Scalability, Reliability
866.518.9273 x 260
Location: US/Pacific
IRC: mage2k

#3Craig Ringer
craig@2ndquadrant.com
In reply to: Erik Jones (#2)
Re: Is there a way to know if trigger is invoked by the code from another trigger

On Mon, 2009-10-12 at 10:36 -0700, Erik Jones wrote:

On Oct 11, 2009, at 10:51 AM, Naoko Reeves wrote:

Could you tell me if there is a way to know if trigger is invoked by
the code from another trigger?
For instance, table A Trigger deletes table B record. While in table
B trigger, I want to know whether this was triggered from table A.

Nothing built in to show you that. You could, however, have your
trigger on table A make an insert or update to a record in some table
that the trigger on table B could then look for.

This is one of those places where transaction-scoped variables would be
really, really nice; a temp table is a bit of a clumsy way to do things.

--
Craig Ringer