Hi!

I'm trying to set up an automated area calculation for the column "Area".
My trigger looks like this:

CREATE OR REPLACE FUNCTION calc_area()
 RETURNS "trigger" AS
$BODY$
BEGIN
       IF (TG_OP = 'INSERT') THEN
           UPDATE test
           SET Area = area(geometry);
ELSIF (TG_OP = 'UPDATE') THEN
           NEW.Area = area(geometry);
           RETURN NEW;
       END IF;
   RETURN NULL;
END;
$BODY$
 LANGUAGE 'plpgsql' VOLATILE;

The INSERT-part works well. But the UPDATE-part does not work. I get the following error:

ERROR: column "geometry" does not exist
ZEILE 1: SELECT area(geometry)
                  ^
ANFRAGE:  SELECT area(geometry)
KONTEXT: PL/pgSQL function "calc_area" line 7 at assignment

Did anybody face the same problem or has anybody got an idea?

greetings,
Johannes
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to