pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: wit <microx@hotpop.com>
To: pgsql-sql@postgresql.org
Subject: check source of trigger
Date: Fri, 20 Sep 2002 15:25:14 +0700
Message-ID: <amem61$1j4o$1@news.hub.org> (raw)

Hello,

I have a question about trigger. I have tables with the following structure:

create table A (
   e_codeA char(5) default '' not null,
   n_codeA varchar(20) default '' not null,
   constraint A_pkey primary key ( e_codeA )
);

create table B (
   e_codeB char(5) default '' not null,
   e_codeA char(5) default '' not null
      constraint e_codeA_ref references A( e_codeA )
      on delete cascade on update cascade,
   n_codeB varchar(20) default '' not null,
   constraint B_pkey primary key ( e_tranB, e_codeA )
);

I have trigger and procedure on table B to capture any change and insert
into table logB:
    create trigger trigger_b before insert or update or delete on B for each
row execute procedure log_change();

When I update e_codeA in table A, the constrain trigger will update e_codeA
in B. My trigger, trigger_b, also was trigged and procedure will record
change into table logB too.
How to write a code in my db procedure to check whether the procedure was
called by normal SQL or was called by cascade trigger.

Regards,
wit







view thread (3+ messages)  latest in thread

Message-ID: <amem61$1j4o$1@news.hub.org>
Permalink:  ../amem61$1j4o$1@news.hub.org/
Also on:    postgresql.org/message-id/amem61$1j4o$1@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: microx@hotpop.com
  Subject: Re: check source of trigger
  In-Reply-To: <amem61$1j4o$1@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox