Problem with an SQL function

Started by Chris M. Gamblealmost 24 years ago2 messagesgeneral
Jump to latest
#1Chris M. Gamble
chris.gamble@cpbinc.com

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...

#2Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Chris M. Gamble (#1)
Re: Problem with an SQL function

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;