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

From hlefebvre
Subject Re: Re: Date of creation and of change
Date
Msg-id 39A65D1D.EB626E7D@lexbase.net
Whole thread Raw
In response to Re: Date of creation and of change  (Andreas Tille <tillea@rki.de>)
Responses Re: Date of creation and of change  (Andreas Tille <tillea@rki.de>)
List pgsql-sql

Andreas Tille wrote:
> 
> On Wed, 23 Aug 2000, hlefebvre wrote:
> 
> > Yes. The keywords NEW / OLD are available only in triggers
> > see
> > http://www.postgresql.org/users-lounge/docs/7.0/user/c40874113.htm#AEN4286
> Well, I believe that, but
> 
> CREATE FUNCTION changed_at_timestamp() RETURNS OPAQUE AS '
>     BEGIN
>         ChangedAt := timestamp(''now'');
>         RETURN NEW;
>     END;
> ' LANGUAGE 'plpgsql';
<snip>
> web=# insert into menu (IdMenu, ...) values (3, ... );
> ERROR:  parser: parse error at or near "changedat"
> 
> What's the problem here. 

No I suppose that the problem is the identifier "changedat" is unknown.

You must probably prefix it : NEW.changedat
CREATE FUNCTION changed_at_timestamp() RETURNS OPAQUE AS '    BEGIN        NEW.ChangedAt := timestamp(''now'');
RETURNNEW;    END;' LANGUAGE 'plpgsql';
 

I didn't test it, but as pgSQL looks like Oracle, it should be ok :-)

regards


pgsql-sql by date:

Previous
From: Andreas Tille
Date:
Subject: Re: Date of creation and of change
Next
From: Andreas Tille
Date:
Subject: Re: Date of creation and of change