Return SIGN function

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
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Return SIGN function

Post 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.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post 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.
Thanks,
Naveen
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post 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.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post 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.
Thanks,
Naveen
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post 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.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

How about IF NUM(In.CheckNumber) THEN IF (In.CheckNumber<0) THEN '-' ELSE '+' ELSE '*'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There is a SIGN function. Read about it in the DataStage BASIC manual.
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