fuction for coverting a character string to numeric value ?

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
raj_cipher
Participant
Posts: 90
Joined: Mon Dec 08, 2003 4:48 am
Location: Chennai

fuction for coverting a character string to numeric value ?

Post by raj_cipher »

HI ,

What is the fuction for coverting a character string to numeric value ?
Think Ahead,
Raj.D
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

First use the the num-Function to check if the value is realy a Number and the isNull-Function to check if a value is coming.

Thereafter you can take the string as number, without an conversion. Sometimes you have 0000-strings before the number therefore we add 0.

IF num(FIELD)=1 THEN IF IsNull(FIELD) THEN "" ELSE FIELD+0 ELSE 999999

Wolfgang

999999 is the Errorcase, there you can decide if you want an other handling.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As Wolfgang says, basically everything inside DataStage is a string. All you need to do is ensure that there are no non-numeric characters in your string before moving it into a numeric field (say, in a database). If you need to do numeric formatting, check out "FMT".
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I suspect the question is about determining the ASCII value of a character. The function for this is SEQ() - provided that you only want to process single-byte characters. For example, SEQ("A") returns 65, and CHAR(65) returns "A".

If you need to process multi-byte characters, then the functions you need to use are UNISEQ() and UNICHAR(). These will provide Unicode code points rather than ASCII code points.

If you want to convert something to its byte-equivalents, use the OCONV() function with "MX0C" - or "MU0C" for multi-byte character sets. For example, OCONV("ABC","MX0C") returns "313233" (that is, 0x31, 0x32, 0x33, but represented as a string of characters).

Perhaps a bit more specificity in the requirement?
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