[postgis-users] Postgresql create function

Tambade, Kedar ktambade at cghtech.com
Mon Feb 4 07:13:24 PST 2013


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

RETURN QUERY select
  count(msgno)::bigint as Tmsgcount
, floor(utc_time) :: double precision as utc_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);

END;
$$ LANGUAGE plpgsql;

Regards,

Kedar Tambade

This electronic mail message and any attached files contain information intended for the exclusive use of the individual or entity to whom it is addressed and may contain information that is propriety, privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any viewing, copying, disclosure or distribution of this information may be subject to legal restriction or sanction. Please notify the sender, by electronic mail or telephone, of any unintended recipients and delete the original message without making any copies.

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 7:57 AM
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/f386a561/attachment.html>


More information about the postgis-users mailing list