I'm using @INROWNUM funtion in one of the columns and rest other column derivations are included with Trim functon in the transformer stage prior to DB2 UDB API output stage. The output table has all the columns defined as NOT NULL. The job is working fine, except that extra spaces are getting inserted into output columns in DB2 table.
The expected output for example shoule be
Col1|Col2|col3|col4|col5
100|1|10|count|189.39|Z
100|2|130|num|37|Z
However actual output that I'm getting is
Col1|Col2|col3|col4|col5
100|1|10|count|189.39|Z
100|2|130|num|37|Z
100|3| | | |Z
100|4| | | |Z
100|5| | | |Z
I don't understand from where the extra spaces are getting inserted(from 3rd row for instance). Can you please share your views on this issue.
Trim function - Extra space in output
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 75
- Joined: Thu Nov 27, 2008 10:12 am
-
- Participant
- Posts: 597
- Joined: Fri Apr 29, 2005 6:19 am
- Location: Singapore
Check whether there is a whitespace coming from source. For e.g. in people soft systems, they use whitespace when a column has blank. Trim of whitespace will still be a whitespace. So you may want to look for other trim options
or
simply use
If Trim(column) = ' ' Then '' Else Trim(column)
or
simply use
If Trim(column) = ' ' Then '' Else Trim(column)
Kandy
_________________
Try and Try again…You will succeed atlast!!
_________________
Try and Try again…You will succeed atlast!!
-
- Participant
- Posts: 75
- Joined: Thu Nov 27, 2008 10:12 am
Thanks a lot for your time and replies.
One other field is defined as smallInt - length (2)
Whitespaces are getting inserted into these three fields mentioned above. Can you please help me to fix this issue.
I have tried the above option. However, I'm still getting the whitespaces.If Trim(column) = ' ' Then '' Else Trim(column)
Two output fields are defined as character datatype - length(20)What are the data types in your job for the fields in question?
One other field is defined as smallInt - length (2)
Whitespaces are getting inserted into these three fields mentioned above. Can you please help me to fix this issue.
-
- Participant
- Posts: 75
- Joined: Thu Nov 27, 2008 10:12 am
Thanks a lot Craig.
I found the solution for this bug. I'm using the following derivation (checking for white spaces) in one of key columns say col6.
If (DSLink1.col3 <> ' ') AND (DSLink2.col4 <> ' ') AND (DSLink3.col5 <> ' ' ) Then @INROWNUM Else 1
The above columns (col3, col4 and col5) are defined as NOT NULL in DB2 and col6 is a composite (primary) key column which would not allow duplicate values. Therefore I'm able to achieve the desired output.
Col1|Col2|col3|col4|col5|col6
100|A|10|count|189.39|Z|1
100|B|130|num|37|Z|2
Pls correct me if I'm wrong. If this is correct then I can close this topic as "Resolved".
Many Thanks
I found the solution for this bug. I'm using the following derivation (checking for white spaces) in one of key columns say col6.
If (DSLink1.col3 <> ' ') AND (DSLink2.col4 <> ' ') AND (DSLink3.col5 <> ' ' ) Then @INROWNUM Else 1
The above columns (col3, col4 and col5) are defined as NOT NULL in DB2 and col6 is a composite (primary) key column which would not allow duplicate values. Therefore I'm able to achieve the desired output.
Col1|Col2|col3|col4|col5|col6
100|A|10|count|189.39|Z|1
100|B|130|num|37|Z|2
Pls correct me if I'm wrong. If this is correct then I can close this topic as "Resolved".
Many Thanks