Re: [GENERAL] Trigger documentation? Need more examples.. pleeeze.. ; -)

From: Henrique Pantarotto <scanner(at)cepa(dot)com(dot)br>
To: Zakkr <zakkr(at)zf(dot)jcu(dot)cz>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Trigger documentation? Need more examples.. pleeeze.. ; -)
Date: 1999-08-20 23:55:50
Message-ID: 9908202057250N.00439@scanner.cepa.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Zakkr,

I love you. It worked!! Your help should keep me busy this weekend..
;-)

Thanks a lot.. I shall bug you again for sure.. j/k.. ;-)

Henrique Pantarotto
Sao Paulo, SP - Brazil

On sex, 20 ago 1999, Zakkr wrote:
> On Fri, 20 Aug 1999, Henrique Pantarotto wrote:
>
> > I would like to know how, from a trigger C function, can I get the "old" and
> > "new" value for an updated field. Is this possible? How do I do that?
> >
> > For example, if I do:
> >
> > update users set username = "clinton" where id = "2400"
>
> example:
> -------
> TupleDesc tupdesc;
> HeapTuple tnew,
> told;
> char *oldvalue,
> *newvalue;
>
> if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) {
> tnew = CurrentTriggerData->tg_newtuple;
> told = CurrentTriggerData->tg_trigtuple;
> }
> tupdesc = CurrentTriggerData->tg_relation->rd_att;
>
> newvalue = SPI_getvalue(tnew, tupdesc, SPI_fnumber(tupdesc, "username"));
> oldvalue = SPI_getvalue(told, tupdesc, SPI_fnumber(tupdesc, "username"));
> ------
>
> NOTE: If you run trigger AFTER|BEFORE insert in CurrentTriggerData
> is set 'tg_trigtuple' only.
>
> > Did you understand? ;-)
>
> And you? :-)
> Zakkr
--
Henrique Pantarotto
CEPAnet Internet Provider
webmaster / analista de sistemas
Email: scanner(at)cepa(dot)com(dot)br
Tel: (011) 5506-8477
Cel: (011) 9706-3444
LINUX FRIEND

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ross J. Reedstrom 1999-08-21 17:33:58 Re: [GENERAL] RV: Serial fields
Previous Message Dmitri G. Chtchekine 1999-08-20 23:39:01 pq_recvbuf: unexpected EOF on client connection