Problem with looping on a table function result

From: "Alexander M(dot) Pravking" <fduch(at)antar(dot)bryansk(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Problem with looping on a table function result
Date: 2003-07-31 22:32:33
Message-ID: 20030731223233.GJ86626@dyatel.antar.bryansk.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I've met the following problem.
I had successfully written a function divide_into_days(timestamp, timestamp)
which returns setof (timestamp, timestamp) pairs - a list of days the
given interval is divided into.

What I want is to use each record from resultset to pass to another
function, something like:

SELECT days.*, summary_stats(days.day_start, days.day_end)
FROM divide_into_days('2003-06-01', '2003-07-01') days;

The problem is that summary_stats function returns a record, so I have
to use SELECT * FROM summary_stats(...). I can't use the following too:

SELECT *
FROM summary_stats(days.day_start, days.day_end) stats,
divide_into_days('2003-06-01', '2003-07-01') days;

(there was a discussion a few days ago about using subselects,
but here's a slightly different case).

I wonder if where's a way to do the trick without writing one more
PL/PgSQL table function doing FOR row IN SELECT ... LOOP or using
client-side loop?

Thanks for your help.

--
Fduch M. Pravking

Browse pgsql-sql by date

  From Date Subject
Next Message Rod Taylor 2003-08-01 00:33:23 Re: join optimization problem
Previous Message Ron Johnson 2003-07-31 21:21:38 Re: EXTERNAL storage and substring on long strings