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

From Andreas Tille
Subject Re: Date of creation and of change
Date
Msg-id Pine.LNX.4.21.0008231541210.22247-100000@wr-linux02.rki.de
Whole thread Raw
In response to Re: Date of creation and of change  (hlefebvre <hlefebvre@lexbase.net>)
List pgsql-sql
On Wed, 23 Aug 2000, hlefebvre wrote:

> create table mytable( CreateDate  timestamp default timestamp('now'),
> ....);  
Thanks, this works.
> CREATE FUNCTION myt_stamp () RETURNS OPAQUE AS
>     BEGIN
>         ChangeDate := timestamp(''now'');
>         RETURN NEW;
>     END;
> ' LANGUAGE 'plpgsql';
I tried:

web=# CREATE FUNCTION changed_at_timestamp () RETURNS OPAQUE AS '
web'#     BEGIN
web'#         ChangeDate := timestamp(''now'');
web'#         RETURN NEW;
web'#     END;
web'# ' LANGUAGE 'plpgsql';
CREATE
web=# select changed_at_timestamp () ;
ERROR:  typeidTypeRelid: Invalid type - oid = 0
web=# 

Is this just the wrong way to test the function?
As a beginner I try to validate each new step I do and so I wonder
if I insert the Trigger you mentioned
> CREATE TRIGGER myt_stamp BEFORE INSERT OR UPDATE ON mytable
>     FOR EACH ROW EXECUTE PROCEDURE myt_stamp();

the function could cause errors.

Sorry, I'm not very familiar with this function stuff :-(.

Kind regards
         Andreas.




pgsql-sql by date:

Previous
From: Andreas Tille
Date:
Subject: Re: Using SETOF in plpgsql function
Next
From: Andreas Tille
Date:
Subject: Re: Date of creation and of change