String Comparision

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
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

String Comparision

Post by zulfi123786 »

Strings when they are compared with each other it happens at the character level i.e character by character comparision, when two strings are of unequal size then is the smaller string padded to make it equal with the longer string, if yes then with which character is it padded with?

Ex 'abcd'<'efghts'

In the above example does the single relational expressions becomes multiple expressions involving one character each time? "a<e", "b<f".....

If so then how is the final value decided, is it based on majority?
or is my understanding completely wrong please enlighten.....

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

Post by ray.wurlod »

You're almost there. Strings are compared character by character. If, when the end of the shorter string is encountered, no difference has been found, then the shorter string is "less than" the longer string.

No padding occurs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

And what if the shorter string is greater than the longer string and the end of shorter string is encountered.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The comparison is character-by-character. Therefore as soon as one character in the shorter string is "greater than" the corresponding character in the other string, previous characters having matched exactly, then the shorter string is "greater than" the longer. For example, "WOLF" is greater than "AARDVARK", "Grease mop" is greater than "Grease ball". If you want to compare the lengths, then compare the lengths. Use the Len() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply