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