Page 1 of 1

String compare

Posted: Thu Feb 21, 2008 10:51 am
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.

Posted: Thu Feb 21, 2008 11:14 am
by kcbland

Posted: Thu Feb 21, 2008 11:14 am
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.

Posted: Thu Feb 21, 2008 11:22 am
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:

Re: String compare

Posted: Thu Feb 21, 2008 12:43 pm
by satya99
Hi,

Concatenate with "*"

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

if Var1 = Var2 then @true else @false

Thanks