Thread: Problem with an SQL function

Problem with an SQL function

From
chris.gamble@CPBINC.com
Date:
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...

Re: Problem with an SQL function

From
Stephan Szabo
Date:
On Fri, 14 Jun 2002 chris.gamble@CPBINC.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;