From: | darren(at)crystalballinc(dot)com |
---|---|
To: | Josué Maldonado <josue(at)lamundial(dot)hn> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Field collection in trigger |
Date: | 2003-09-01 20:25:05 |
Message-ID: | Pine.LNX.4.44.0309011622550.23940-100000@thread.crystalballinc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Try the following using pltcl
CREATE OR REPLACE FUNCTION foo() RETURNS TRIGGER AS '
foreach id [array names OLD] {
if { $OLD($id) != $NEW($id) {
# do your logging in here or flags whatever you wish
}
}
return [array get NEW]
' LANGUAGE 'pltcl';
HTH
Darren
On Mon, 1 Sep 2003, Josué Maldonado wrote:
> Hi Doug,
>
> Thanks for anwsers, do you have some sample code or URL where I can get
> more info on this. I don't know C or Perl but really need to get this done.
>
> Thanks,
>
> Doug McNaught wrote:
>
> >Josué Maldonado <josue(at)lamundial(dot)hn> writes:
> >
> >
> >
> >>Hello list,
> >>
> >>First of all, excuse me if this is not the right place to ask my question.
> >>
> >>Is there a way in postgresql to loop to all the fields of a given
> >>table and compare the OLD and NEW value for each field. I need to make
> >>an audit table that must contain only the fields changed after and
> >>insert/update.
> >>
> >>
> >
> >You should be able to do this in a Perl or C trigger. It can't be
> >done in PL/pgSQL without writing a custom trigger for each table that
> >hard-codes all the field names.
> >
> >-Doug
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 3: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> > message can get through to the mailing list cleanly
> >
> >
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match
>
--
Darren Ferguson
From | Date | Subject | |
---|---|---|---|
Next Message | CSN | 2003-09-01 20:33:38 | sort ignoring the, a, ... |
Previous Message | Andreas Fromm | 2003-09-01 20:09:45 | inserting via "on insert" rule |