Covert comma separated decimal field to DataStage decimal

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
Munish
Participant
Posts: 89
Joined: Sun Nov 19, 2006 10:34 pm

Covert comma separated decimal field to DataStage decimal

Post 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)?
MK
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Use

Code: Select all

StringToDecimal(CONVERT(',','',in.Col))
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
harryn
Participant
Posts: 3
Joined: Thu Jan 18, 2007 10:16 pm

Post 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?
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post 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).
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post 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.
Post Reply