[postgis-users] Postgresql create function

Francois Hugues hugues.francois at irstea.fr
Mon Feb 4 07:04:31 PST 2013


Hello,
 
Maybe you should try to write the end of your funtion like this :
 
return query
    your query
return;
 
Hugues.
 

________________________________

From: postgis-users-bounces at lists.osgeo.org
[mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of tasha dewasi
Sent: Monday, February 04, 2013 1:57 PM
To: PostGIS Users Discussion
Subject: [postgis-users] Postgresql create function


hello, 
I am trying to create a function, but instead of returning me all the
rows from a table, it is just returning me count of rows
I don't understand whats wrong.
Please guide me

here's my code:

CREATE or REPLACE FUNCTION DEMO(latitude double precision, longitude
double precision)
RETURNS TABLE (Tmsgcount bigint,utc_time double precision) as $$
BEGIN

create temporary table Transmitter as select count(msgno)
TransCount,floor(utc_time) Trans_time from transmitter_primary where 
st_dwithin(st_geogfromtext('SRID=4326;POINT(' || longitude || ' ' ||
latitude || ')'),geog,10)='t' group by floor(utc_time) order by
floor(utc_time);

RETURN QUERY select * from Transmitter;

END;
$$ LANGUAGE plpgsql;


and it returns me just this value
13034;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130204/711a238a/attachment.html>


More information about the postgis-users mailing list