Skip site navigation (1) Skip section navigation (2)

Re: date range to set of dates expansion

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
Subject: Re: date range to set of dates expansion
Date: 2012-01-19 16:20:06
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Thursday, January 19, 2012 7:59:27 am Gary Stainburn wrote:
> The following code works in 8.4 but not 8.3.
> Anyone know why, or what I need to do to change it?
> SELECT aid, asid,
>        date_range (asdate, afdate)::date AS asdate,
>        acomments
> FROM availability
> In 8.4 it returns the expanded dataset as required. In 8.3 I get:
> ERROR:  set-valued function called in context that cannot accept a set
> CONTEXT:  PL/pgSQL function "date_range" line 4 at RETURN NEXT

As to why it works in 8.4 vs 8.3

"Support set-returning functions in SELECT result lists even for functions that 
return their result via a tuplestore (Tom)

In particular, this means that functions written in PL/pgSQL and other PL 
languages can now be called this way.'

In 8.3- I believe you could only call it as

SELECT * from date_range (asdate, afdate)::date AS asdate;

> Is there a way to use the integer only generate_series in 8.3 to generate
> dates by typecasting to/from integers?

Adrian Klaver

In response to


pgsql-sql by date

Next:From: Steve CrawfordDate: 2012-01-19 16:50:53
Subject: Re: date range to set of dates expansion
Previous:From: Gary StainburnDate: 2012-01-19 16:10:15
Subject: Re: SOLVED - date range to set of dates expansion

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group