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: Re: Date of creation and of change |
Date: | 2000-08-23 14:35:49 |
Message-ID: | 39A3E145.55A6F495@lexbase.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Andreas Tille wrote:
> 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?
Yes. The keywords NEW / OLD are available only in triggers
see
http://www.postgresql.org/users-lounge/docs/7.0/user/c40874113.htm#AEN4286
> 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-08-23 14:35:58 | Re: Re: Date of creation and of change |
Previous Message | Jan Wieck | 2000-08-23 14:27:02 | Re: Using SETOF in plpgsql function |