Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id AD20D2BF80 for ; Fri, 16 Dec 2011 00:56:20 -0400 (AST) Received: from nm7-vm4.bullet.mail.ne1.yahoo.com ([98.138.91.167]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1RbPqD-0001MZ-RF for pgsql-sql@postgresql.org; Fri, 16 Dec 2011 04:56:20 +0000 Received: from [98.138.90.55] by nm7.bullet.mail.ne1.yahoo.com with NNFMP; 16 Dec 2011 04:56:04 -0000 Received: from [98.138.226.167] by tm8.bullet.mail.ne1.yahoo.com with NNFMP; 16 Dec 2011 04:56:04 -0000 Received: from [127.0.0.1] by omp1068.mail.ne1.yahoo.com with NNFMP; 16 Dec 2011 04:56:04 -0000 X-Yahoo-Newman-Id: 212301.422.bm@omp1068.mail.ne1.yahoo.com Received: (qmail 97166 invoked from network); 16 Dec 2011 04:56:04 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:References:Mime-Version:In-Reply-To:X-Apple-Yahoo-Original-Message-Folder:Content-Type:Content-Transfer-Encoding:Message-Id:Cc:X-Mailer:From:X-Apple-Yahoo-Replied-Msgid:Subject:Date:To; b=0pB9SuA+QaR3mXhWYUPav5ljk0NeUqa3X20//vMkCCxLN2gl5pWwswcv/t2S0Pik8o2rPVXABvQ2JL9g90zcrlwT8x/3bo/pQSh3Kgvl/LjyNIJtysD5kYNDjeEu6pXQAHIddyxkmmQ0LIad2Z8nFgVrFp7xdhj05Z9ks3lGSDo= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1324011364; bh=kaGUztrGE3/H40YepkNEWr4cQLzTw0H2yyBsGlVTL30=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:References:Mime-Version:In-Reply-To:X-Apple-Yahoo-Original-Message-Folder:Content-Type:Content-Transfer-Encoding:Message-Id:Cc:X-Mailer:From:X-Apple-Yahoo-Replied-Msgid:Subject:Date:To; b=wyxnnymV2XpdzcGWEsCOT7GfFHQZ8G2k5XtFXM33+fZ9U6Dm1+jlkRs0p1ru+mN/enmao6uPeuLuW5fPU4G5/4aLbkvCcoGEJ/T7AH6uwjlIiSlh4+xPa0r2L/AlvVYtT+ZmZAyFdt4IXre6Xt+48PfT7APoULTSf7C/9Ug+AGA= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: ldPed3IVM1nZrLVDRW5sJEiENRspap5jVrbcgE0j6Qq4.87 Ca8KfeI0LmvEV8GFr5ufb2sG5XKsqsr8kPtFGxw4SvQe6SpgpM6AfYb.l8mw XeNocpWnujrHE6N_lZQAReo3gljEaOWiGuPmUigWeqAQExPMH1uQU7YkXLVG sEnRnqWPdGG2sNdqq9ZK1RsXrbVKbgT27haS1mqsx4.wXuKMeDNHYVFobFs7 FRJat4xnR45ovQRWbcohfrJb7P7IXUPCp_LSohHi_dQmc4Nxkhi0E7NRMFIH 7MWyKtQs6ejNvk.NUVvEiV5oS_cAZ73CgRbLRyKnW63iujnyZZrJl4dUt6iu YquXcJRHzFSI0YLFZt2msKYRzMIcISW_wAeS.SOqzttYfSilAorHDXHFI3Bf gJoqP.Q-- X-Yahoo-SMTP: mpGJl6eswBD2IBufoVEg0Pa8gg-- Received: from [192.12.17.102] (polobo@24.93.23.188 with xymcookie) by smtp113-mob.biz.mail.ne1.yahoo.com with SMTP; 15 Dec 2011 20:56:03 -0800 PST References: <1356101.40bZh1B7cs@linux-12> Mime-Version: 1.0 (iPad Mail 8J2) In-Reply-To: <1356101.40bZh1B7cs@linux-12> X-Apple-Yahoo-Original-Message-Folder: Inbox Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: Cc: "pgsql-sql@postgresql.org" X-Mailer: iPad Mail (8J2) From: David Johnston X-Apple-Yahoo-Replied-Msgid: 1_431645_AO2kiGIAAM41TurGRgqsEnRi/Qk Subject: Re: using a generated series in function Date: Thu, 15 Dec 2011 23:56:05 -0500 To: John Fabiani X-Pg-Spam-Score: -4.3 (----) X-Archive-Number: 201112/56 X-Sequence-Number: 36117 On Dec 15, 2011, at 23:16, John Fabiani wrote: > Hi, >=20 > I am attempting (without success) use the generated series of dates that c= ome=20 > from: > select (cast(date_trunc('week', '2011-11-20'::date ) as date) + (i+6)) as=20= > week_date from generate_series(0,84,7) i=20 >=20 > in a function. > select function_name(integer, date); -- function returns a numeric >=20 > This does NOT work: > select (function_name(303, week_date::date)) as week_date where week_date i= n=20 > (select (cast(date_trunc('week', '2011-11-20'::date ) as date) + (i+6)) as= =20 > week_date from generate_series(0,84,7) i ) >=20 > The error is: > ERROR: column "week_date" does not exist > LINE 1: select (xchromasun._chromasun_getqtyordered(303, week_date::... >=20 > I hope I can do this? What am I doing wrong? > Johnf >=20 >=20 "select ... as week_date where week_date in ..." You are missing a FROM clause for the main select; the only FROM you have is= part of the IN target subquery. David J.