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@natlab.research.philips.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@postgresql.org
Aasmund Midttun Godal
aasmund@godal.com - http://www.godal.com/
+47 40 45 20 46