Page 1 of 1

Covert comma separated decimal field to DataStage decimal

Posted: Wed Feb 21, 2007 8:56 pm
by Munish
Any one know a good way to convert an input field of comma separated decimal (for example 12,345.67) to DataStage decimal field? It seems that the implicit conversion doesn't work. Any formatting option can be used with explicit conversion (such as StringToDecimal function)?

Posted: Wed Feb 21, 2007 11:34 pm
by DSguru2B
Use

Code: Select all

StringToDecimal(CONVERT(',','',in.Col))

Posted: Tue Feb 27, 2007 12:02 am
by harryn
Is this the only way to handle this situation? I would have thought that comma in decimal figure is basic stuff and should be handled either implicitly or explicitly with format string?

Posted: Tue Feb 27, 2007 12:25 am
by kumar_s
Its how the data is read from source. If its extracted as character, it has to be converted into Decimal and as the process the comma need to be excluded.
Defaults tab in Job Property will also help in specifying a different Decimal separator other than .(period).

Posted: Tue Feb 27, 2007 9:25 am
by DSguru2B
harryn wrote:Is this the only way to handle this situation? I would have thought that comma in decimal figure is basic stuff and should be handled either implicitly or explicitly with format string?
As Ray would put it sometimes, "Stop thinking like a server developer !!!"
DataType conversions are present in Enterprise Edition for this very reason, that type conversions need to be explicit, even for basic stuff.

Posted: Tue Feb 27, 2007 12:26 pm
by vmcburney
The parallel sequential file input stage is supposed to handle implicit conversions of fields to numeric and decimal - unless the extract developer has cocked it up and put formatting into a data exchange field, such as the commas. You could dig into the column properties and see if you can define a mask for the field. There are various format options you can add to an input column. I don't use them that much, I prefer to explicitly convert it in a transformer for transparency.