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

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: function returning a merge of the same query executed X time
Дата
Msg-id 5537BC65.1070106@BlueTreble.com
обсуждение исходный текст
Ответ на function returning a merge of the same query executed X time  (Marc-André Goderre <magoderre@cgq.qc.ca>)
Список pgsql-general
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


В списке pgsql-general по дате отправления:

Предыдущее
От: Marc-André Goderre
Дата:
Сообщение: function returning a merge of the same query executed X time
Следующее
От: Geoff Winkless
Дата:
Сообщение: Re: function returning a merge of the same query executed X time