Page 1 of 1

Need to write decimal(10) column to sequential file

Posted: Mon May 03, 2004 6:50 pm
by Gazelle
Scenario:
ColumnA is a varchar field (eg. value=A).
ColumnB is a decimal[10,0] field (eg. value=76543210).
ColumnC is a varchar field (eg. value=X).

Requirement:
Write to a comma-delimited sequential file. ColumnB is not to have a leading space or decimal point.
eg. the record should be: A,76543210,X

Problems:
1. By default, the record is written as: A, 76543210.,X
2. Using "AsInteger(ColumnA) function produces: A,76540000,X
3. Using DecimalToString(ColumnA) function produces: A, 007654321,X
4. The out format can only be specified for integer types, but 10-digits can cause an overflow in an integer data type.

Solution:
One solution is to use a bunch of nested Trim statements (both inefficient and inelegant):
Trim(Trim(TrimF(DecimalToString(ColumnA,"fix_zero")),".","T"),"0","L")

Does anyone know of a better solution to produce the required output?

Posted: Wed May 05, 2004 1:44 am
by Gazelle
My thanks to asadi for this one:
Map the decimal[10] field to BigInt

Much nicer!

Posted: Fri Apr 21, 2006 1:37 pm
by vinaymanchinila
Hi,
Is there a way to avoid the space before 007654321

Using DecimalToString(ColumnA) function produces: A, 007654321,X


I am able to do it with a transformer but would not like to have the transformer just to trim one field.