Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group