Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A60B043CEB9 for ; Thu, 19 Jan 2012 12:20:26 -0400 (AST) Received: from mail-iy0-f174.google.com ([209.85.210.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rnuiu-0002nJ-BF for pgsql-sql@postgresql.org; Thu, 19 Jan 2012 16:20:26 +0000 Received: by iagf6 with SMTP id f6so97936iag.19 for ; Thu, 19 Jan 2012 08:20:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; bh=J2sopbK5MCFDS/7ZN2DNCizXw8y610/gd4ZjQz/iJtQ=; b=KIcrY1hXMcO+qPvd1rqr4tGCZ44yTC3QAthgvX8W82mrPXoAyYDgSmK+k3+w67g8kt uE3IXbONtdQI6kbcBQmZn7J8tAF9TMTysf/FLNcnewPBlz7limf+NTZN9YaB5X5waCyg VR447ANL+wpZLZXAxCYrMT0RfGH1J+17gKDMU= Received: by 10.42.243.198 with SMTP id ln6mr26653333icb.29.1326990011273; Thu, 19 Jan 2012 08:20:11 -0800 (PST) Received: from tucker.localnet (c-24-17-164-54.hsd1.wa.comcast.net. [24.17.164.54]) by mx.google.com with ESMTPS id q30sm102507932ibc.1.2012.01.19.08.20.09 (version=SSLv3 cipher=OTHER); Thu, 19 Jan 2012 08:20:09 -0800 (PST) From: Adrian Klaver To: pgsql-sql@postgresql.org Subject: Re: date range to set of dates expansion Date: Thu, 19 Jan 2012 08:20:06 -0800 User-Agent: KMail/1.13.5 (Linux/2.6.32-37-generic; KDE/4.4.5; i686; ; ) Cc: Gary Stainburn References: <201201190713.34333.gary.stainburn@ringways.co.uk> <201201191516.16802.gary.stainburn@ringways.co.uk> <201201191559.27698.gary.stainburn@ringways.co.uk> In-Reply-To: <201201191559.27698.gary.stainburn@ringways.co.uk> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201201190820.06564.adrian.klaver@gmail.com> X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201201/92 X-Sequence-Number: 36263 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 http://www.postgresql.org/docs/8.4/interactive/release-8-4.html "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 adrian.klaver@gmail.com