Re: Date of creation and of change - Mailing list pgsql-sql

From hlefebvre
Subject Re: Date of creation and of change
Date
Msg-id 39A3A9EB.E6AF09D5@lexbase.net
Whole thread Raw
In response to Date of creation and of change  (Andreas Tille <tillea@rki.de>)
Responses Re: Date of creation and of change  (Andreas Tille <tillea@rki.de>)
Re: Date of creation and of change  (Andreas Tille <tillea@rki.de>)
List 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.


pgsql-sql by date:

Previous
From: Andreas Tille
Date:
Subject: Date of creation and of change
Next
From: tolik@aaanet.ru (Anatoly K. Lasareff)
Date:
Subject: Re: Null function parameters