Decimal Data Changed to Zero

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
sarathchandrakt
Participant
Posts: 50
Joined: Fri Aug 29, 2014 1:32 pm
Location: Mumbai

Decimal Data Changed to Zero

Post by sarathchandrakt »

I am Taking Data from flatfile and loading to sequentual file. In flat file it is just a single column which I am dividing into many columns based on requirment. In one case i have to pick data from 21st to 25th char of source file and have to save it as decimal in target.
For Example, the data is '+2014' i need to store it as decimal. So I created a Decimal column and saved 21st to 25th char of source file in that column. but the data is getting saved as '00000.' instead of '2014.' or '02014.'.

Please help me. Please let me know what am I doing wrong here?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Show us the expression you used to extract the five characters.

I suspect that you have used an incorrect syntax.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sarathchandrakt
Participant
Posts: 50
Joined: Fri Aug 29, 2014 1:32 pm
Location: Mumbai

Post by sarathchandrakt »

I have created a decimal column in transformer output and gave the following expression...

Table_Read.Source_Col[21,25]
ssnegi
Participant
Posts: 138
Joined: Thu Nov 15, 2007 4:17 am
Location: Sydney, Australia

Post by ssnegi »

Use StringToDecimal function in the transformer. It could be the case that the substring is being treated as character.
StringToDecimal(Table_Read.Source_Col[21,25])
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Right. Use explicit transformations, don't just take strings and shove them into other datatypes. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The second argument is length, not finishing position. Try:

Code: Select all

Table_Read.Source_Col[21,5] 
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Got distracted and forgot to note that. D'oh.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sarathchandrakt
Participant
Posts: 50
Joined: Fri Aug 29, 2014 1:32 pm
Location: Mumbai

Post by sarathchandrakt »

Thank you for noticing it. I am new to DataStage so i am still confused about the syntax. Thank you all. I corrected the syntax and that fixed the issue and for safe side i used explicit transformation too.
Post Reply