Re: Function won't compile

From: "Aasmund Midttun Godal" <postgresql(at)envisity(dot)com>
To: jvbussel(at)natlab(dot)research(dot)philips(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Function won't compile
Date: 2001-10-24 21:51:06
Message-ID: 20011024215106.1254.qmail@ns.krot.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

1. Trigger procedures need to return opaque.
2. 'now' should probably be now().
3. Can the SQL language handle this?

Here is how I did more or less the same:

DROP TRIGGER auto_modified_trig ON en_dirs;
DROP FUNCTION auto_modified();

CREATE FUNCTION auto_modified() RETURNS opaque AS '
BEGIN
NEW.modified = now();
RETURN NEW;
END;
' LANGUAGE 'plpgsql';

CREATE TRIGGER auto_modified_trig BEFORE INSERT OR UPDATE ON en_dirs
FOR EACH ROW EXECUTE PROCEDURE auto_modified();

-- It may not be the _right_ way to do it, but I think it works.

Regards,

Aasmund
On Wed, 24 Oct 2001 15:33:02 +0200, "Joop van Bussel" <jvbussel(at)natlab(dot)research(dot)philips(dot)com> wrote:
> Hi,
>
> Does anybody know why the function insert_case() won't compile. When I
> INSERT a new record I always get the following error message :
>
> NOTICE: plpgsql: ERROR during compile of insert_case near line 1
> "RROR: parse error at or near "
>
> Below is the function and trigger. ('Now' is surrounded with single quotes)
>
> CREATE FUNCTION insert_case () RETURNS INTEGER AS '
> BEGIN
> NEW.date_created := ''now'';
> END;
> ' LANGUAGE 'SQL';
>
> CREATE TRIGGER trg_insert_case BEFORE INSERT ON pfdcase FOR EACH ROW EXECUTE
> PROCEDURE insert_case();
>
>
> Thanks
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

Aasmund Midttun Godal

aasmund(at)godal(dot)com - http://www.godal.com/
+47 40 45 20 46

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-10-24 21:55:51 Re: MATCH FULL flawed?
Previous Message Dr. Evil 2001-10-24 21:42:29 Re: Function won't compile