Received: from mx2.imaginet.fr (artemis.imaginet.fr [195.68.75.24]) by hub.org (8.10.1/8.10.1) with ESMTP id e7NEMDN26894 for ; Wed, 23 Aug 2000 10:22:13 -0400 (EDT) Received: from lexbase.net ([195.68.125.34]) by mx2.imaginet.fr (8.9.3/8.8.8) with ESMTP id QAA05366; Wed, 23 Aug 2000 16:20:08 +0200 (MET DST) Message-ID: <39A3E145.55A6F495@lexbase.net> Date: Wed, 23 Aug 2000 16:35:49 +0200 From: hlefebvre Organization: LEXBASE X-Mailer: Mozilla 4.73 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Andreas Tille , PostgreSQL SQL Subject: Re: Re: Date of creation and of change References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200008/247 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.