Page 1 of 1

Return SIGN function

Posted: Mon Aug 15, 2005 2:26 pm
by I_Server_Whale
Hi All,

Is there any function in DataStage which returns the SIGN of a number field. It is also OK if it checks for the sign and returns true or false.

Is there any function which does that?

I have a field with both negative and positive numeric values. I need to capture the SIGN of that number and implement a 'If Then Else' logic.

Please let me know if anyone has used such a function or any other method. Thanks much,

Naveen.

Posted: Mon Aug 15, 2005 2:48 pm
by pnchowdary
Hi NaveenD,

You can convert the numeric field to a string and then use the substring function and check for a "-" sign in the first character of the string. Based on the result, you can apply your processing logic.

Once your processing is done, you can convert the string back to numeric and pass it to the target field.

Posted: Mon Aug 15, 2005 2:56 pm
by I_Server_Whale
Hi pnchowdary,

I need not do the conversion. I can just use the 'Count' function to check if the count of "-" = 0 or not and then implement my logic.

But I wanted to know whether there is any function which checks for the sign and me being ignorant of that.

But I want to thank you very much for your reply.

Many Thanks,

Naveen.

Posted: Mon Aug 15, 2005 3:03 pm
by pnchowdary
Hi NaveenD,

I believe even the Count function expects a string and therefore you would have to convert numeric to string to use that function.

Count Function "Counts the number of times a substring occurs in a string."

Please correct me, if I am wrong.

Posted: Mon Aug 15, 2005 3:10 pm
by I_Server_Whale
Hi pnchowdary,

My source was of type decimal. And I didn't not convert it to a string. But the Count function still works.

What do you think the reason would be? My source is a fixed flat file.

Thanks much,
Naveen.

Posted: Tue Aug 16, 2005 1:44 am
by ArndW
How about IF NUM(In.CheckNumber) THEN IF (In.CheckNumber<0) THEN '-' ELSE '+' ELSE '*'

Posted: Tue Aug 16, 2005 2:43 am
by ray.wurlod
There is a SIGN function. Read about it in the DataStage BASIC manual.