pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedGeneral trigger function
3+ messages / 3 participants
[nested] [flat]
* General trigger function
@ 2002-06-12 07:48 GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>
0 siblings, 1 reply; 3+ messages in thread
From: GRIMOIS Eric @ 2002-06-12 07:48 UTC (permalink / raw)
To: pgsql-sql
Hi all
I read in the doc than a same function can be used for several triggers.
I tried to create a function who updates a field with a timestamp and
another field with the user name. This function is fired by triggers in
several tables.
It only works if updated fields have same names in all tables. I failed to
create a function where fields names are parameters of the function.
What's the way to do that ?
Thanks.
Eric GRIMOIS
Analyste programmeur
SEI - CPAM du Val d'Oise
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: General trigger function
@ 2002-06-12 20:32 Jan Wieck <JanWieck@Yahoo.com>
parent: GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>
0 siblings, 1 reply; 3+ messages in thread
From: Jan Wieck @ 2002-06-12 20:32 UTC (permalink / raw)
To: GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>; +Cc: pgsql-sql
GRIMOIS Eric wrote:
>
> Hi all
>
> I read in the doc than a same function can be used for several triggers.
> I tried to create a function who updates a field with a timestamp and
> another field with the user name. This function is fired by triggers in
> several tables.
> It only works if updated fields have same names in all tables. I failed to
> create a function where fields names are parameters of the function.
You could do that with the EXECUTE functionality. But that
causes *every* execution of these statemets not beeing
cacheable, so it'll have an impact on performance.
Jan
>
> What's the way to do that ?
> Thanks.
>
> Eric GRIMOIS
> Analyste programmeur
> SEI - CPAM du Val d'Oise
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: General trigger function
@ 2002-06-13 08:50 Richard Huxton <dev@archonet.com>
parent: Jan Wieck <JanWieck@Yahoo.com>
0 siblings, 0 replies; 3+ messages in thread
From: Richard Huxton @ 2002-06-13 08:50 UTC (permalink / raw)
To: pgsql-sql
On Wednesday 12 Jun 2002 9:32 pm, Jan Wieck wrote:
> GRIMOIS Eric wrote:
> > Hi all
> >
> > I read in the doc than a same function can be used for several triggers.
> > I tried to create a function who updates a field with a timestamp and
> > another field with the user name. This function is fired by triggers in
> > several tables.
> > It only works if updated fields have same names in all tables. I failed
> > to create a function where fields names are parameters of the function.
>
> You could do that with the EXECUTE functionality. But that
> causes *every* execution of these statemets not beeing
> cacheable, so it'll have an impact on performance.
Or look in the cookbook linked from techdocs.postgresql.org - there's an
example in there of a "trigger maker" which builds last-changed tracking
triggers and functions. You do something like:
select lastchg_addto('TABLE-NAME','TIMESTAMP-COLUMN-NAME')
And it creates the relevant function and trigger code then EXECUTEs it.
Shouldn't take much to alter it for your purposes
- Richard Huxton
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-06-13 08:50 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-06-12 07:48 General trigger function GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>
2002-06-12 20:32 ` Jan Wieck <JanWieck@Yahoo.com>
2002-06-13 08:50 ` Richard Huxton <dev@archonet.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