[postgis-users] RE: Trigger updata lines

Obe, Regina robe.dnd at cityofboston.gov
Wed Aug 15 05:27:59 PDT 2007


Couple of things.  One you are using GeometryFromText incorrectly and 2
your code is just wrong.  Not just missing froms.  I think below should
work although I haven't tested it.
 
Try instead
 
CREATE OR REPLACE FUNCTION update_links() RETURNS "trigger"
    AS 
$BODY$
BEGIN
    UPDATE links SET the_geom = MakeLine(NEW.the_geom,ends.the_geom) 
        FROM nodes As ends
        WHERE NEW.name = links.from_node and ends.name = links.to_node;
 
    UPDATE links SET the_geom = MakeLine(starts.the_geom,NEW.the_geom) 
        FROM nodes As starts
        WHERE starts.name = links.from_node and NEW.name =
links.to_node;
 
RETURN NEW;
END
$BODY$
    LANGUAGE plpgsql;
CREATE TRIGGER update_links_update
  AFTER UPDATE
  ON nodes
  FOR EACH ROW
  EXECUTE PROCEDURE update_links();

________________________________

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Broun Uganda
Sent: Wednesday, August 15, 2007 5:28 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] RE: Trigger updata lines



Sorry the error i get is:
 

Query failed: ERROR:  missing FROM-clause entry for table "nodes" ....

Broun Uganda





________________________________

	From: tekuganda at hotmail.com
	To: postgis-users at postgis.refractions.net
	Subject: Trigger updata lines
	Date: Tue, 14 Aug 2007 23:24:44 +0300
	
	

	I want to create a trigger that updates lines' geometry
depending on the position of 2 points (from_node & to_node). If i move
a point connecting two or more lines, the ends of lines should also move
and follow the point. I wrote the following trigger but it gives me
error that am giving multiple geometry.
	 
	CREATE OR REPLACE FUNCTION update_links() RETURNS "trigger"
	    AS 
	'
	DECLARE
	starts character varying;
	ends character varying;
	BEGIN
	starts = NEW.name WHERE nodes.name = links.from_node;
	ends = NEW.name WHERE nodes.name = links.to_node;
	UPDATE links SET the_geom =
GeometryFromtext(starts.the_geom,ends.the_geom) ;
	RETURN NEW;
	END'
	    LANGUAGE plpgsql;
	CREATE TRIGGER update_links_update
	  AFTER UPDATE
	  ON nodes
	  FOR EACH ROW
	  EXECUTE PROCEDURE update_links();
	 
	 
	Thanks for your help
	
	
	
________________________________

	Live Earth is coming.  Learn more about the hottest summer event
- only on MSN. Check it out!
<http://liveearth.msn.com/?source=msntaglineliveearthwlm>  


________________________________

Hotmail to go? Get your Hotmail, news, sports and much more! Check out
the New MSN Mobile <http://mobile.msn.com>  



-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070815/2751b98d/attachment.html>


More information about the postgis-users mailing list