Hi
I have an integer field of length 11. Now I need to attach Zeros before it, in the empty spaces.
e.g if input column is 124125,then I must get 00000124125
What I have done is - IntegerToDecimal(input column) in stage variable.....then Str('0',11-input column):input column in derivation.
But I am getting 00000000 instead of say 00000124125. Someone plz help.
Regards
Arnie
attaching 0 before an integer
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 101
- Joined: Mon Aug 13, 2007 2:32 am
An integer field does not contain leading zeroes. If you convert your integer to a string then you can use the str function as you mentioned. If you write this integer column to a text file you can also prepend leading zeroes (basically because everything going into a text file is a string).
So in order to really answer your question we need to know where this integer column is being written to.
So in order to really answer your question we need to know where this integer column is being written to.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Fmt() is a BASIC function and thus not available in parallel Transformer stage. As Arnd says, integers do not have leading zeroes; they are stored internally in binary format. Therefore, if you need leading zeroes, you also need an appropriate data type (a string of some kind). But ask yourself whether the leading zeroes are really necessary.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You've all missed the vital Len() function. Assuming the target is a string data type: The conversion to string for the Len() function will occur implicitly.
Code: Select all
Str('0',11-Len(input column)):input column
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.