cast from decimal to float

Database

cast from decimal to float

I am trying to cast one decimal field to  float. I get an error "bad character" . I am not sure why ? is it not advisible to convert decimal to float type?

does anyone has any teradata manual link for sql reference for such kind of queries ? 

3 REPLIES
Supporter

Re: cast from decimal to float

cast decimal to float shouldn't be a problem


select cast(123456789012345678 as decimal(18,0)) as dec_val,

              cast(dec_val as float) as float_val;

select cast(999999999999999999 as decimal(18,0)) as dec_val,

              cast(dec_val as float) as float_val;

select cast(123456789.012345678 as decimal(18,9)) as dec_val,

              cast(dec_val as float) as float_val;

select cast(999999999.999999999 as decimal(18,9)) as dec_val,

              cast(dec_val as float) as float_val;


work all fine.


Your error message is much more indicating that you do a char to float conversion and at least one row doesn't contain a float or decimal value...


Check show select of your query to see what you really access...

Re: cast from decimal to float

Hi Ulrich

Yeah you are right. I too tried to cast from decimal to float and it worked fine. As you mentioned, there might be one particular record creating the problem.

I am not able to figure out which insert is causing the problem. any way to find this record. What is the show select command that you mentioned. Cld u pls give me its syntax.

Supporter

Re: cast from decimal to float

Just type

SHOW 

in front of your

SELECT ...

;

statement and submit the query.