Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id C4FD02BF80 for ; Fri, 16 Dec 2011 00:16:45 -0400 (AST) Received: from [76.14.161.106] (helo=newserver.jfcomputer.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RbPDv-0000kD-Pw for pgsql-sql@postgresql.org; Fri, 16 Dec 2011 04:16:45 +0000 Received: from localhost (unknown [127.0.0.1]) by newserver.jfcomputer.com (Postfix) with ESMTP id 1CE8AFC8E for ; Fri, 16 Dec 2011 04:16:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at site Received: from newserver.jfcomputer.com ([127.0.0.1]) by localhost (linux-jfp8.site [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QH3VkulXnX46 for ; Thu, 15 Dec 2011 20:16:28 -0800 (PST) Received: from linux-12.localnet (unknown [192.168.1.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johnf@jfcomputer.com) by newserver.jfcomputer.com (Postfix) with ESMTPSA id 6AF025732 for ; Thu, 15 Dec 2011 20:16:28 -0800 (PST) From: John Fabiani To: pgsql-sql@postgresql.org Subject: using a generated series in function Date: Thu, 15 Dec 2011 20:16:27 -0800 Message-ID: <1356101.40bZh1B7cs@linux-12> User-Agent: KMail/4.7.2 (Linux/3.1.0-1.2-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Host-Lookup-Failed: Reverse DNS lookup failed for 76.14.161.106 (failed) X-Pg-Spam-Score: 1.6 (+) X-Archive-Number: 201112/55 X-Sequence-Number: 36116 Hi, I am attempting (without success) use the generated series of dates that come from: select (cast(date_trunc('week', '2011-11-20'::date ) as date) + (i+6)) as week_date from generate_series(0,84,7) i in a function. select function_name(integer, date); -- function returns a numeric This does NOT work: select (function_name(303, week_date::date)) as week_date where week_date in (select (cast(date_trunc('week', '2011-11-20'::date ) as date) + (i+6)) as week_date from generate_series(0,84,7) i ) The error is: ERROR: column "week_date" does not exist LINE 1: select (xchromasun._chromasun_getqtyordered(303, week_date::... I hope I can do this? What am I doing wrong? Johnf