Re: Problem with an SQL function

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: <chris(dot)gamble(at)CPBINC(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Problem with an SQL function
Date: 2002-06-15 08:23:00
Message-ID: 20020615012054.X24594-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Fri, 14 Jun 2002 chris(dot)gamble(at)CPBINC(dot)com wrote:

> Is it possible to define the following in language='SQL' ?
>
> select (69.1 * $1 - $2) as x, (53 * $3 - $4) as y;
> select sqrt(x * x + y * y) as distance;
>
> I was trying to create this but keep getting the error that x does not
> exist...

I don't think you can do it as the above, but for the simple
example above, you can probably make it one query with a
subselect in from.
select sqrt(x*x+y*y) as distance from
(select (69.1 * $1 - $2) as x, (53 * $3 - $4) as y) as foo;

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2002-06-15 10:13:27 Re: Fw: read this and puke
Previous Message Justin Clift 2002-06-15 07:44:38 Re: Mac os x