Number to Character Datatype Translation
Posted in 1998
Topics: Stored Procedures & SPL, Server Administration, Data Types & Schema Design, Triggers, Constraints & Referential Integrity
I have a column defined as decimal(32).
I have an insert trigger defined on the table with that column which
uses a stored procedure to convert the column value to character and
insert the result into a column defined as varchar(35) in another table.
The converion is done in the procedure by defining a varchar(35)
variable, passing in the decimal(32) value, using the LET command to
assign the decimal(32) value to the varchar(35) variable, and then
returning the varchar(35) value to the trigger for insertion into the
varchar(35) column. The procedure follows:
create procedure convert_to_char(decimalfloatcol decimal(32)) returningvarchar(35);
define decimalfloat_str varchar(35);
let decimalfloat_str = decimalfloatcol;
return decimalfloat_str;
end procedure;
This seems to work most of the time. However, if I insert something like
0.0000000000000000000000000000000000123456789 into the decimal(32)
column, the varchar(35) column receiving the converted value gets
0.0000000000000000.
Selecting from the decimal(32) column (using dbaccess) yieds a value of
1.23456789e-35. Why don't I get this value when converting to
varchar(35)? Is there any way to obtain this value during the conversion
from decimal(32) to varchar(35), or any way to get the decimal expansion
of the value from a varchar(35) conversion?
Thanks,
G.Carter
mailto:greg.carter@homemail.com
mailto:greg.carter@workmail.com
http://www.webaccess.net/~greg.carter