From: | David Johnston <polobo(at)yahoo(dot)com> |
---|---|
To: | John Fabiani <johnf(at)jfcomputer(dot)com> |
Cc: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: using a generated series in function |
Date: | 2011-12-16 04:56:05 |
Message-ID: | B8982C63-B4D6-4088-BDA1-200D957B51B2@yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Dec 15, 2011, at 23:16, John Fabiani <johnf(at)jfcomputer(dot)com> wrote:
> 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
>
>
"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.
From | Date | Subject | |
---|---|---|---|
Next Message | Misa Simic | 2011-12-16 09:30:53 | Re: using a generated series in function |
Previous Message | John Fabiani | 2011-12-16 04:16:27 | using a generated series in function |