Re: Character to Numeric Conversion - IDS 7.2
Posted in 2004
Athumani Mlinga wrote:
PLEASE do no post MIME/HTML, it triples the bandwidth needed to
download your posting.
> I have a character field with numeric values but cannot perform any
> numeric function unless I convert into numeric type during querying. Is
> there anything similar to TO_NUM() function in IDS 7.2 to do this?
Just add zero to the value in the column, hmm, well actually as long
as the column does indeed just contain numerics in all rows that are
being selected, the engine should not object to performing ANY
calculations using that column:
select (numeric_col + 1000)
from oddly_designed_table
where ...;
If you are not trying to perform calculations in the SQL, but in the
app that is fetching the value, that's not a problem either. IDS will
happily convert the data automatically to the type of the host
variable as long as the conversion is possible and sensible. In ESQL:
int int_to_hold_string;
short int_ind;
exec sql declare cur cursor for
select numeric_col
from oddly_designed_table
where keycol matches "a*";
exec sql open cur;
for (;;) {
exec sql fetch cur
into :int_to_hold_string indicator int_ind;
if (sqlca.sqlcode <= 0)
break;
<process data>
}
...
Have you tried it?
Art S. Kagel
> Regards,
> Athumani.
> sending to informix-list