Need to write decimal(10) column to sequential file

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Gazelle
Premium Member
Premium Member
Posts: 108
Joined: Mon Nov 24, 2003 11:36 pm
Location: Australia (Melbourne)

Need to write decimal(10) column to sequential file

Post 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?
Gazelle
Premium Member
Premium Member
Posts: 108
Joined: Mon Nov 24, 2003 11:36 pm
Location: Australia (Melbourne)

Post by Gazelle »

My thanks to asadi for this one:
Map the decimal[10] field to BigInt

Much nicer!
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post 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.
Thanks,
Vinay
Post Reply