String compare

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
zhoum00
Premium Member
Premium Member
Posts: 6
Joined: Thu May 22, 2003 12:30 pm

String compare

Post by zhoum00 »

Hi,

In a transform job, I try to compare 2 stage variables containing a string value. Here are an exemple of my problem...

The first variable value is : "00E019"
The second variable value is : "00E017"

The problem is that the following verification : If Var1 = Var2
return always true. The reason is because DataStage is taking the "e" as a Exponent.

I don't want a mathematical compare between this 2 strings but a real string compare.

Can some one help me on this one.

Thanks.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Haven't seen that problem before, but if that's really the problem you can try one of the 'string' functions noted in the BASIC manual pdf. Specifically, the SCMP function:

Code: Select all

Use the SCMP function to compare two string numbers and return one of the
following three numbers: -1 (less than), 0 (equal), or 1 (greater than). If
string.number.1 is less than string.number.2, the result is 1. If they are equal, the
result is 0. If string.number.1 is greater than string.number.2, the result is 1. You can
use this function in any expression where a string or string number is valid.
Either string number can be a valid number or string number. Computation is
faster with string numbers.
If either string number contains nonnumeric data, an error message is generated
and 0 is used instead of the nonnumeric data. If either string number evaluates to
the empty string, null is returned.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or there's always what Ken posted. Don't know why, but I always forget about 'compare' for some reason. D'oh! :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
satya99
Participant
Posts: 104
Joined: Thu Nov 30, 2006 1:22 pm

Re: String compare

Post by satya99 »

Hi,

Concatenate with "*"

Var1 "*" : "00E019"
Var2 "*" : "00E019"

if Var1 = Var2 then @true else @false

Thanks
satya
Post Reply