pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Johnston <polobo@yahoo.com>
To: John Fabiani <johnf@jfcomputer.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: using a generated series in function
Date: Thu, 15 Dec 2011 23:56:05 -0500
Message-ID: <B8982C63-B4D6-4088-BDA1-200D957B51B2@yahoo.com> (raw)
In-Reply-To: <1356101.40bZh1B7cs@linux-12>
References: <1356101.40bZh1B7cs@linux-12>

On Dec 15, 2011, at 23:16, John Fabiani <johnf@jfcomputer.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.




view thread (12+ messages)  latest in thread

Message-ID: <B8982C63-B4D6-4088-BDA1-200D957B51B2@yahoo.com>
Permalink:  ../B8982C63-B4D6-4088-BDA1-200D957B51B2@yahoo.com/
Also on:    postgresql.org/message-id/B8982C63-B4D6-4088-BDA1-200D957B51B2@yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: polobo@yahoo.com, johnf@jfcomputer.com
  Subject: Re: using a generated series in function
  In-Reply-To: <B8982C63-B4D6-4088-BDA1-200D957B51B2@yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox