Re: Fwd: Set-valued function in wrong context - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Fwd: Set-valued function in wrong context
Date
Msg-id 20081009131748.O71903@megazone.bigpanda.com
Whole thread Raw
In response to Fwd: Set-valued function in wrong context  (Raymond O'Donnell <rod@iol.ie>)
Responses Re: Fwd: Set-valued function in wrong context  (Raymond O'Donnell <rod@iol.ie>)
List pgsql-general
On Thu, 9 Oct 2008, Raymond O'Donnell wrote:

> gfc_bookings=# select * from make_time_series('11:00', '14:00', 30);
> ERROR:  set-valued function called in context that cannot accept a set
> CONTEXT:  PL/pgSQL function "make_time_series" line 10 at for over
> select rows
>
> Now, I know what the error means, and I reckon it's because of the
> cast(), but for the life of me I can't see what to do about it. Any help
> will be appreciated...

>   for ATime in
>     select start_time + s.a
>     from cast(generate_series(0, TotalMins, mins_delta) || ' minutes' as
> interval) as s(a)

I think you'd end up wanting something like:
 FROM ( select a * interval '1 minute' from generate_series(0, TotalMins,
mins_delta) as s(a) ) as s(a)

I changed the concatenation and cast into an interval multiply, but you
could easily do things the other way as well.


pgsql-general by date:

Previous
From: Martin Pitt
Date:
Subject: Re: [Pkg-postgresql-public] Postgres major version support policy on Debian
Next
From: Raymond O'Donnell
Date:
Subject: Re: Fwd: Set-valued function in wrong context