<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body><div style="text-align: left;">Dear All<br><br><span style="font-weight: bold;">I 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?</span><br style="font-weight: bold;"><span style="font-weight: bold;">The Trigger is thus:</span><br><span style="font-style: italic;">CREATE FUNCTION calc_point() RETURNS "trigger"</span><br style="font-style: italic;"><span style="font-style: italic;">    AS 'BEGIN</span><br style="font-style: italic;"><span style="font-style: italic;">NEW.point_x = NEW.the_geom[0];</span><br style="font-style: italic;"><span style="font-style: italic;">NEW.point_y = NEW.the_geom[1];</span><br style="font-style: italic;"><span style="font-style: italic;">   RETURN NEW;</span><br style="font-style: italic;"><span style="font-style: italic;"> END'</span><br style="font-style: italic;"><span style="font-style: italic;">    LANGUAGE plpgsql;</span><br style="font-style: italic;"><br style="font-style: italic;"><br style="font-style: italic;"><span style="font-style: italic;">CREATE TRIGGER calc_point_update</span><br style="font-style: italic;"><span style="font-style: italic;">    BEFORE UPDATE ON nodes</span><br style="font-style: italic;"><span style="font-style: italic;">    FOR EACH ROW</span><br style="font-style: italic;"><span style="font-style: italic;">    EXECUTE PROCEDURE calc_point();</span><br style="font-style: italic;"><br style="font-style: italic;"><span style="font-style: italic;">CREATE TRIGGER calc_point_insert</span><br style="font-style: italic;"><span style="font-style: italic;">    BEFORE INSERT ON nodes</span><br style="font-style: italic;"><span style="font-style: italic;">    FOR EACH ROW</span><br style="font-style: italic;"><span style="font-style: italic;">    EXECUTE PROCEDURE calc_point();<br><span style="font-weight: bold;">The error that i get is thus:<br></span></span><pre>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 array<br>CONTEXT:  SQL statement "SELECT   $1 [0]"<br>PL/pgSQL function "calc_point" line 2 at assignment]<br>Backtrace:</pre><br></div><br /><hr />Live Earth is coming.  Learn more about the hottest summer event - only on MSN. <a href='http://liveearth.msn.com?source=msntaglineliveearthwlm' target='_new'>Check it out!</a></body>
</html>