Re: column: on update update?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 7 May 2008 16:49:03 +0200
Michael Monnerie <michael.monnerie@xxxxxxxxxxxxxxxx> wrote:

> > the other option is to add an after update trigger, and manually set
> > lastupdate then.
> 
> Would that be correct? I never did it and looked purely into docs:
> 
> CREATE FUNCTION awlupdate()
>     AS 'UPDATE awl SET lastupdate=CURRENT_TIMESTAMP;'
>     LANGUAGE SQL;
> 
> CREATE TRIGGER awlupdate AFTER UPDATE ON awl FOR EACH ROW
> EXECUTE PROCEDURE awlupdate();

I'd prefer this version:
CREATE FUNCTION awlupdate RETURNS TRIGGER AS '
BEGIN
  NEW.lastupdate = now();
  RETURN NEW;
END' LANGUAGE plpgsql;
CREATE TRIGGER... the same.

But both methods are fine. The only thing is, the function must return TRIGGER
AFAIK.



-- 
Üdvölettel,

Czuczy Gergely
Harmless Digital Bt
mailto: gergely.czuczy@xxxxxxxxxxx
Tel: +36-30-9702963

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux