[postgis-users] column has pseudo type record

Denis Rouzaud denis.rouzaud at gmail.com
Tue Feb 21 02:35:06 PST 2012


Hi all,

I have a table of nodes and I am trying to add a column with the closest 
node id and distance info.

I am trying this by using a function to calculate id and distance and  
by displaying them in a view:

CREATE OR REPLACE FUNCTION closest_node(integer,geometry) RETURNS TABLE 
(id integer,distance double precision) AS
     $$     SELECT node_id AS id , 
MIN(ST_Distance($2,nodes.wkb_geometry)) AS distance
         FROM nodes
         WHERE node_id != $1
         GROUP BY node_id ;$$
LANGUAGE SQL;

CREATE OR REPLACE VIEW nodes_view AS
     SELECT *, closest_node(node_id,wkb_geometry)
     FROM pipe_nodes;

I get the following error:
  ERROR:  column "closest_node" has pseudo-type record

Can someone explain me why?

I had a look at this post
http://stackoverflow.com/questions/7097126/including-a-set-of-rows-in-a-view-column
and I tried using the type and cast, but I get the same error.

Thanks!
Denis

PS: if someone has a better idea, I'll take it with no shame!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120221/07953821/attachment.html>


More information about the postgis-users mailing list