Using Trim - Even then getting Blank Spaces

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
udankar
Premium Member
Premium Member
Posts: 14
Joined: Tue Oct 18, 2005 6:27 am
Location: India

Using Trim - Even then getting Blank Spaces

Post by udankar »

Hi,

While extracting data from a table - I used TRIM to avoid unwanted blank spaces after the column value.

But I get space even after using TRIM and it fails to match with the look up file which does not have any unwanted blankspace - Subsequently my job fails.

What is the way out to remove the Blank space .

Thanks and regards,

Udankar
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The TRIM function will remove spaces, but it might not remove characters that are not spaces but display as such. In your job add an extra test output column that displays the ASCII value of the last character in your test string - use

Code: Select all

SEQ(In.YourColumnName[LEN(In.YourColumnName),1])
and I will be willing to wager money that the value is not 32 decimal.
jasper
Participant
Posts: 111
Joined: Mon May 06, 2002 1:25 am
Location: Belgium

Post by jasper »

I'm not sure if this applies to datastage also, but in most db's you have to watch for the difference between varchar and char.
the string 'aa' as varchar(10) is not equal to 'aa' as char(10).
I think datastage works to same way.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Jasper,

no, DataStage doesn't. There is no such thing as CHAR in DataStage, if a job reads CHAR columns they are padded with blanks. I think that in this case the TRIM() function isn't doing what is expected because the padding is not the normal space (char(32)) but nulls (char(000)) and that is why I asked the poster to test what values are actually in the string.

When working with PX jobs your comment about the differences between VarChar() and Char() are applicable.
Post Reply