Question: MySQL - Changing x^y to POWER(x,y)

Hi:

I am using Maple + MySql and can execute queries like this:

 

nZero:=10^(-6);

ee:=7*u+6*v-2*w; 

ss:=convert(ee,string):

sql:=sprintf("SELECT n FROM centers WHERE  ABS(%s)<%a ", ss, nZero ):

Problems arise when ee contains `^` operator, because MySql does not understand this operator, but the function POWER() , ie, in MySql x^y must be written as POWER(x,y).

Example 

ee:=u^2+v^2-w^2

must be rewritten as:
ee:=POWER(u,2)+POWER(v,2)-POWER(w,2) 

before converting to string and quering.

I tried:

> POWER := proc (x, y) return x^y end proc;
> applyrule(X::algebraic^Y::algebraic = POWER(X, Y), ee);

but it seems tha evaluation of POWER has to be delayed in some way.

 

Any hint?

Thanks in advance

C.L.

 

 

Please Wait...