Trim on char fields
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
Trim on char fields
Hi,
I am trying to read a sequential file having 10 columns all defined as varchar.
A transformer stage follows the sequential file where i am converting some varchar to char. There is a field 'GMAB' of length 3 having value 'IN ' for all the records.
In the transformer stage i am using TrimLeadingTrailing function on the field and mapping to o/p as char(3). now when i am checking using the condition " If TrimLeadingTrailing(GMAB) = 'IN' Then 1 Else 0 " in another transformer which is the last stage of my job, is giving the value '0'.
What could be the possible reason
I am trying to read a sequential file having 10 columns all defined as varchar.
A transformer stage follows the sequential file where i am converting some varchar to char. There is a field 'GMAB' of length 3 having value 'IN ' for all the records.
In the transformer stage i am using TrimLeadingTrailing function on the field and mapping to o/p as char(3). now when i am checking using the condition " If TrimLeadingTrailing(GMAB) = 'IN' Then 1 Else 0 " in another transformer which is the last stage of my job, is giving the value '0'.
What could be the possible reason
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
All things are possible, but think about it. Out of the box the only values that may match to the char(1) are 1 character values in the char(3) field, is that what you need? Or are they a match if the first character is the same in both fields? You'd have to tell us what your match rules are.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
you are right. o in char(only those values which are of length 13) field have to be matched with the other char(1) field. so i want to trim the char(3) field so as to remove any leading spaces, is this possible without changing the datatype of char(3) to varchar. If so please suggest.chulett wrote:All things are possible, but think about it. Out of the box the only values that may match to the char(1) are 1 character values in the char(3) field, is that what you need? Or are they a match if the first character is the same in both fields? You'd have to tell us what your match rules are.
Hmmm... 13? New number here. Sure, leading spaces can be trimmed from a char field. It's the trailing ones being discussed as problematic here, the "padding" that is automatically done for the data type to its full size. Sorry if that wasn't clear.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
sory it was 3 not 13. one more doubt!! what happen it the trailing spaces are trimmed from a char field and mapped to a field of same length .chulett wrote:Hmmm... 13? New number here. Sure, leading spaces can be trimmed from a char field. It's the trailing ones being discussed as problematic here, the "padding" that is automatically done for the data type to its full size. Sorry if that wasn't clear.
Ex: if ID='IN ' now if i trim it would become 'IN' and if i map this to a field char(3) would it again pad a space???
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
It will pad, and it will use whatever character is set as the value of APT_STRING_PADCHAR environment variable as the pad character. If this is a space, then yes, it will pad with spaces. If this is Ctrl-@, then it will pad with Ctrl-@ (NUL) characters.
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.