Search Postgresql Archives

Re: function returning a merge of the same query executed X time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/22/15 8:14 AM, Marc-André Goderre wrote:
     select row_to_json(q)
	from (select row_number() over() as id, sum(cost) as total_cost,sum(length) as total_length,json_agg(row_to_json(r)) as data
		from (select * from cm_get_loop_route_4(2, 10, -73.597070, 45.544083))r)q

Untested...

CREATE FUNCTION ...(
  ...
  , iterations int
)
LANGUAGE sql AS
$body$
    select row_to_json(q)
from (select row_number() over() as id, sum(cost) as total_cost,sum(length) as total_length,json_agg(row_to_json(r)) as data
		from (select * from cm_get_loop_route_4(2, 10, -73.597070, 45.544083))r)q
		, generate_series(1, iterations) i
$body$
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux