Re: Date of creation and of change

From: Andreas Tille <tillea(at)rki(dot)de>
To:
Cc: PostgreSQL SQL <pgsql-sql(at)hub(dot)org>
Subject: Re: Date of creation and of change
Date: 2000-08-23 13:44:12
Message-ID: Pine.LNX.4.21.0008231541210.22247-100000@wr-linux02.rki.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 23 Aug 2000, hlefebvre wrote:

> create table mytable( CreateDate timestamp default timestamp('now'),
> ....);
Thanks, this works.

> CREATE FUNCTION myt_stamp () RETURNS OPAQUE AS
> BEGIN
> ChangeDate := timestamp(''now'');
> RETURN NEW;
> END;
> ' LANGUAGE 'plpgsql';
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?
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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Tille 2000-08-23 13:46:10 Re: Using SETOF in plpgsql function
Previous Message Anatoly K. Lasareff 2000-08-23 13:37:36 Re: Null function parameters