Re: Re: Date of creation and of change

From: hlefebvre <hlefebvre(at)lexbase(dot)net>
To: Andreas Tille <tillea(at)rki(dot)de>
Cc: PostgreSQL SQL <pgsql-sql(at)hub(dot)org>
Subject: Re: Re: Date of creation and of change
Date: 2000-08-25 11:48:45
Message-ID: 39A65D1D.EB626E7D@lexbase.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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'');
RETURN NEW;
END;
' LANGUAGE 'plpgsql';

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

regards

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Tille 2000-08-25 13:02:28 Re: Date of creation and of change
Previous Message Andreas Tille 2000-08-25 11:06:07 Re: Date of creation and of change