pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcheck source of trigger
3+ messages / 3 participants
[nested] [flat]
* check source of trigger
@ 2002-09-20 08:25 wit <microx@hotpop.com>
0 siblings, 2 replies; 3+ messages in thread
From: wit @ 2002-09-20 08:25 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: check source of trigger
@ 2002-09-20 09:23 Richard Huxton <dev@archonet.com>
parent: wit <microx@hotpop.com>
1 sibling, 0 replies; 3+ messages in thread
From: Richard Huxton @ 2002-09-20 09:23 UTC (permalink / raw)
To: wit <microx@hotpop.com>; pgsql-sql
On Friday 20 Sep 2002 9:25 am, wit wrote:
> 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.
There are a number of "special" variables defined if you are a trigger
procedure (not just OLD and NEW) - is that what you were after (Programmers
manual, ch 23.9)
- Richard Huxton
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: check source of trigger
@ 2002-09-26 18:13 Rajesh Kumar Mallah. <mallah@trade-india.com>
parent: wit <microx@hotpop.com>
1 sibling, 0 replies; 3+ messages in thread
From: Rajesh Kumar Mallah. @ 2002-09-26 18:13 UTC (permalink / raw)
To: wit <microx@hotpop.com>; pgsql-sql
Hi,
In case you doing all this to replicate tables
conside contrib/dbmirror it does it fairly elegantly.
regds
mallah.
On Friday 20 September 2002 13:55, wit wrote:
> 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
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)
Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-09-26 18:13 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-09-20 08:25 check source of trigger wit <microx@hotpop.com>
2002-09-20 09:23 ` Richard Huxton <dev@archonet.com>
2002-09-26 18:13 ` Rajesh Kumar Mallah. <mallah@trade-india.com>
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