[postgis-users] Automated area calculating
Johannes Sommer
johann.online at gmx.de
Sat Feb 2 12:01:06 PST 2008
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
More information about the postgis-users
mailing list