Re: Date of creation and of change

From: hlefebvre <hlefebvre(at)lexbase(dot)net>
To: Andreas Tille <tillea(at)rki(dot)de>, PostgreSQL SQL <pgsql-sql(at)hub(dot)org>
Subject: Re: Date of creation and of change
Date: 2000-08-23 10:39:39
Message-ID: 39A3A9EB.E6AF09D5@lexbase.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Anatoly K. Lasareff 2000-08-23 11:46:14 Re: Null function parameters
Previous Message Andreas Tille 2000-08-23 10:10:38 Date of creation and of change