[postgis-users] Using Trigger function to manipulate coordinates

Broun Uganda tekuganda at hotmail.com
Thu Jun 21 02:54:54 PDT 2007


Dear AllI wrote the following filter for taking coordinates from the_geom to my point_x & point_y columns but it is giving errors. Could anybody be of help?The Trigger is thus:CREATE FUNCTION calc_point() RETURNS "trigger"    AS 'BEGINNEW.point_x = NEW.the_geom[0];NEW.point_y = NEW.the_geom[1];   RETURN NEW; END'    LANGUAGE plpgsql;CREATE TRIGGER calc_point_update    BEFORE UPDATE ON nodes    FOR EACH ROW    EXECUTE PROCEDURE calc_point();CREATE TRIGGER calc_point_insert    BEFORE INSERT ON nodes    FOR EACH ROW    EXECUTE PROCEDURE calc_point();The error that i get is thus:message:   Unable to update feature in database Message: DB Error: unknown error  Userinfo: UPDATE public.nodes SET the_geom = GeometryFromText('POINT(493464.81111115 1994876.04)', -1) , point_x = '493267.50928400003', point_y = '1996402.58174999990' WHERE gid = 4 [nativecode=ERROR:  cannot subscript type geometry because it is not an arrayCONTEXT:  SQL statement "SELECT   $1 [0]"PL/pgSQL function "calc_point" line 2 at assignment]Backtrace:
_________________________________________________________________
Play free games, earn tickets, get cool prizes! Join Live Search Club. 
http://club.live.com/home.aspx?icid=CLUB_wlmailtextlink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070621/78cd82f5/attachment.html>


More information about the postgis-users mailing list