Received: from mx2.imaginet.fr (artemis.imaginet.fr [195.68.75.24]) by hub.org (8.10.1/8.10.1) with ESMTP id e7NAPYT41400 for ; Wed, 23 Aug 2000 06:25:34 -0400 (EDT) Received: from lexbase.net ([195.68.125.34]) by mx2.imaginet.fr (8.9.3/8.8.8) with ESMTP id MAA21678; Wed, 23 Aug 2000 12:23:53 +0200 (MET DST) Message-ID: <39A3A9EB.E6AF09D5@lexbase.net> Date: Wed, 23 Aug 2000 12:39:39 +0200 From: hlefebvre Organization: LEXBASE X-Mailer: Mozilla 4.73 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Andreas Tille , PostgreSQL SQL Subject: Re: Date of creation and of change References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200008/237 Andreas Tille wrote: > > Hello, > > could someone enlighten a fairly beginner how to define columns > of a table with the following features: > > CreateDate DEFAULT value should store current date and time create table mytable( CreateDate timestamp default timestamp('now'), ....); > ChangeDate DEFAULT value at creation as above and a Trigger > function which stores data end time of any change > to the data set must be something like that : CREATE FUNCTION myt_stamp () RETURNS OPAQUE AS BEGIN ChangeDate := timestamp(''now''); RETURN NEW; END; ' LANGUAGE 'plpgsql'; CREATE TRIGGER myt_stamp BEFORE INSERT OR UPDATE ON mytable FOR EACH ROW EXECUTE PROCEDURE myt_stamp(); > I hope someone has this quite usual feature handy or at least a > pointer where this is described. > > Thank you very much > > Andreas.