Trim the data

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
deva
Participant
Posts: 104
Joined: Fri Dec 29, 2006 1:54 pm

Trim the data

Post by deva »

Hi,
I am loading the data into database. I have one column in target table. Its length is varchar(40), some times the Incomming data is more than 40 charactors. so those records are rejecting.

I am using trim() to remove leading charactors. But the trim is not working, what is the reason? records are rejecting even If we use trimB or Trim.

Can any one suggest on this.

Thanks in advanse
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What are the "leading characters" that you want to trim? What syntax of the Trim() function you are using? TrimB() trims trailing white space characters, not leading - you need TrimF() for leading white space. Do your data in fact have leading white space?

Further, if you have 45 non-white-space characters followed or led by zero or more white space characters, Trim() will leave 45 characters.

You probably need a Left() function or substring operator, possibly in conjunction with Trim(), to achieve the effect you require; that is, to limit the output to not more than 40 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.
mohandl
Participant
Posts: 43
Joined: Tue Dec 26, 2006 7:01 am
Location: pune

Post by mohandl »

I think we should have to use Left() function to truncate to 40 char.
Trim function is used to eliminate Spaces

Regards,
Mohan
MOHAN
mohandl
Participant
Posts: 43
Joined: Tue Dec 26, 2006 7:01 am
Location: pune

Post by mohandl »

I think we should have to use Left() function to truncate to 40 char.
Trim function is used to eliminate Spaces

Regards,
Mohan
MOHAN
dhanashreepanse
Participant
Posts: 25
Joined: Fri Jan 11, 2008 12:49 am
Location: Pune, India

Post by dhanashreepanse »

You can try Trim(Left(incoming column,40)).
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

First trim the data then use left() to truncate it. But as ray suggested, check what those characters are before even going with the above rule.
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
Post Reply