Trim Functions

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
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Trim Functions

Post by JDionne »

I am trying to use the trim function to help identify a blank string field and then with a If then Else statment trun it into a Null
This is my code

If Trim(Transform_Full_File.FNAME, "R") = '' Then @Null Else Transform_Full_File.FNAME

Unfortuanatly it does not work, though it makes all the sence in the world to me.
Any Thoughts?
Jim
datastagedummy
Participant
Posts: 56
Joined: Thu Feb 13, 2003 6:08 pm
Location: USA

Post by datastagedummy »

Try using

If Len(Trim(Transform_Full_File.FNAME)) = 0 Then @Null Else Transform_Full_File.FNAME
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

quote:Originally posted by datastagedummy
[br]Try using

If Len(Trim(Transform_Full_File.FNAME)) = 0 Then @Null Else Transform_Full_File.FNAME



:( I got the same result using that bit of logic...any other thoughts?
inter5566
Premium Member
Premium Member
Posts: 57
Joined: Tue Jun 10, 2003 1:51 pm
Location: US - Midwest

Post by inter5566 »

Jim,

When you specify the R option with the trim statement, you need to pick a value you want to -R-emove. Perhaps DS assumed that you wanted to remove nulls. Either way, I believe that the R option will never remove all characters in the string, it reduces to one occurance. I have successfully used trim(link.fieldname)="" I don't know if the double quotes are required or if singles will work. Also use caution with the @null system variable, I recall having strange things happen when using it.

Hope this helps,

Steve
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

quote:Originally posted by inter5566
[br]Jim,

When you specify the R option with the trim statement, you need to pick a value you want to -R-emove. Perhaps DS assumed that you wanted to remove nulls. Either way, I believe that the R option will never remove all characters in the string, it reduces to one occurance. I have successfully used trim(link.fieldname)="" I don't know if the double quotes are required or if singles will work. Also use caution with the @null system variable, I recall having strange things happen when using it.

Hope this helps,

Steve


Steve,
That worked like a charm!!!!
Thanx Man
Jim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The second argument to TRIM is the character to remove. You were asking to remove leading, trailing and multiple "R" characters! D'oh!

Good that you have something working. I usually prefer to check for single space character as well, for example:
If Trim(link.column) > " " Then link.column Else @NULL

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
xli
Charter Member
Charter Member
Posts: 74
Joined: Fri May 09, 2003 12:31 am

Post by xli »

If you just want to identify a blank string containing one or more space, there is a built-in tranform function StringIsSpace under Tranformssdk directory in DataStage Manager. If you cannot find it, the basic code to check a blank string is like :

If Not(IsNull(Transform_Full_File.FNAME) or Transform_Full_File.FNAME = "") and len(Trim(Transform_Full_File.FNAME, " ", "A")) = 0
then @NULL
else Transform_Full_File.FNAME

xiong
Post Reply