Page 1 of 1

Decimal Data Changed to Zero

Posted: Fri Aug 29, 2014 1:56 pm
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?

Posted: Fri Aug 29, 2014 2:31 pm
by ray.wurlod
Show us the expression you used to extract the five characters.

I suspect that you have used an incorrect syntax.

Posted: Fri Aug 29, 2014 11:45 pm
by sarathchandrakt
I have created a decimal column in transformer output and gave the following expression...

Table_Read.Source_Col[21,25]

Posted: Sat Aug 30, 2014 4:02 am
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])

Posted: Sat Aug 30, 2014 8:52 am
by chulett
Right. Use explicit transformations, don't just take strings and shove them into other datatypes. :wink:

Posted: Sat Aug 30, 2014 3:41 pm
by ray.wurlod
The second argument is length, not finishing position. Try:

Code: Select all

Table_Read.Source_Col[21,5] 

Posted: Sat Aug 30, 2014 4:12 pm
by chulett
Got distracted and forgot to note that. D'oh.

Posted: Mon Sep 01, 2014 3:29 am
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.