Data Stage function extracting only numbers

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
Umbix62
Participant
Posts: 79
Joined: Mon Jan 16, 2006 2:47 pm

Data Stage function extracting only numbers

Post by Umbix62 »

I'm looking for a DataStage function that recognize and extract the numeric character from a string. For example

I have a variable with this value:

"Ab12gh3s4"

The function have to returns "1234". I can created a function to do that but before I would know if it already exists a DataStage funtion able to do this type of data extraction.

Thank you everybody

Umberto
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

Use MC/A function with oconv.
Umbix62
Participant
Posts: 79
Joined: Mon Jan 16, 2006 2:47 pm

Post by Umbix62 »

kaps wrote:Use MC/A function with oconv.
I just tried, before reading your answer, the oconv function using "MCN" as second parameter and it works well. Is it the same? Anyway thank you for you help.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

MCN with OCONV extracts only numbers. You can also look at the function DIGITS(). It does the exact same thing.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

DIGITS is a Transform, not a function. Makes the whole 'MCN' thing easier to understand in the job. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Actually thats what i meant to say, a Transform function. I dont know why i categorize everything as a 'function' :) Bound by habit i guess.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Umbix62
Participant
Posts: 79
Joined: Mon Jan 16, 2006 2:47 pm

Post by Umbix62 »

DSguru2B wrote:MCN with OCONV extracts only numbers. You can also look at the function DIGITS(). It does the exact same thing.
It's exactly what I want. I want to extract only digits from the input string, rejecteting all other character.

I saw the online DataStage manuals and now I know the differences between "MCN" and "MC/A". I have to use "MCN" for reformatting the input string without the alphabetic characters.

Thank you very much

Have a nice day

Umberto
Post Reply