<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi all,<br>
<br>
I have a table of nodes and I am trying to add a column with the
closest node id and distance info.<br>
<br>
I am trying this by using a function to calculate id and distance
and by displaying them in a view:<br>
<br>
CREATE OR REPLACE FUNCTION closest_node(integer,geometry) RETURNS
TABLE (id integer,distance double precision) AS <br>
$$ SELECT node_id AS id ,
MIN(ST_Distance($2,nodes.wkb_geometry)) AS distance<br>
FROM nodes<br>
WHERE node_id != $1 <br>
GROUP BY node_id ;$$<br>
LANGUAGE SQL;<br>
<br>
CREATE OR REPLACE VIEW nodes_view AS<br>
SELECT *, closest_node(node_id,wkb_geometry)<br>
FROM pipe_nodes;<br>
<br>
I get the following error:<br>
ERROR: column "closest_node" has pseudo-type record<br>
<br>
Can someone explain me why?<br>
<br>
I had a look at this post<br>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<a
href="http://stackoverflow.com/questions/7097126/including-a-set-of-rows-in-a-view-column">http://stackoverflow.com/questions/7097126/including-a-set-of-rows-in-a-view-column</a><br>
and I tried using the type and cast, but I get the same error.<br>
<br>
Thanks!<br>
Denis<br>
<br>
PS: if someone has a better idea, I'll take it with no shame!<br>
<br>
<br>
</body>
</html>