Re: [postgis-users] Problem using set-returning functions - Mailing list pgsql-sql

From Markus Schaber
Subject Re: [postgis-users] Problem using set-returning functions
Date
Msg-id 4427F6DF.7070104@logix-tt.com
Whole thread Raw
List pgsql-sql
Hi, Regina,

Obe, Regina DND\MIS wrote:

> Actually I suspect no set returning function created in pgsql will work
> the way you are trying to do it.  Not sure why.  The dump is done in c
> and plugged in and I think it explicitly generates a tuple in the target
> set for every output.
> 
> Try rewriting your function to something like this and see if it works
> 
> CREATE OR REPLACE FUNCTION generate_x (geom geometry)
> RETURNS SETOF double precision AS
> '
>     SELECT X(geometryn($1,index))
>     FROM generate_series(1, npoints($1)) index;
> 
> ' LANGUAGE 'sql' IMMUTABLE STRICT;

Yes, it seems to work. This will solve the OPs case.


But it is still a good question whether it is possible to accomplish
this using plpgsql.

Thanks,
Markus

-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org


pgsql-sql by date:

Previous
From: Markus Schaber
Date:
Subject: Re: Permission to Select
Next
From: John DeSoi
Date:
Subject: Re: Problem using set-returning functions