Aryaraj
20th February 2014, 11:46
Hi,

How to convert the string value into double type variable. Here is the code i have tried -
function get.lbt.value()
{
domain tcamnt lbtval
double refe.g
extern domain tcmcs.str30 refe
string.scan(refe,"%f",refe.g)

select whinh312.refe
from whinh312
where whinh312.refe = :refe.g
selectdo
lbtval = (gamnt / (refe.g))*100
endselect

}
also i tried it by using val function but its not working.

the error is - Error SQL: SQLState QP010: Parameter 'refe.g' should be of type STRING instead of type REAL.

bhushanchanda
20th February 2014, 13:02
Where exactly the error is caused? Check the line no when compilation error occurs. Also, I see you are trying to compare a string with a number which will give you error.

function get.lbt.value()
{
domain tcamnt lbtval
double refe.g
extern domain tcmcs.str30 refe
extern domain tcrefa tmp.refe
string.scan(refe,"%f",refe.g)

tmp.refe = str$(refe.g)

select whinh312.refe
from whinh312
where whinh312.refe = :tmp.refe
selectdo
lbtval = (gamnt / (refe.g))*100
endselect

}

Or if the problem is caused during scanning:-

function get.lbt.value()
{
domain tcamnt lbtval
double refe.g
extern domain tcmcs.str30 refe
extern domain tcrefa tmp.refe
string.scan(refe,"%s",tmp.refe)

refe.g = val(tmp.refe)

select whinh312.refe
from whinh312
where whinh312.refe = :tmp.refe
selectdo
lbtval = (gamnt / (refe.g))*100
endselect

}