How to check for numeric characters field by field

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
dsexplorer
Premium Member
Premium Member
Posts: 23
Joined: Wed Apr 16, 2008 5:34 am
Location: Prague,Cz

How to check for numeric characters field by field

Post by dsexplorer »

Hi colleagues-

I have to implement the below requirement-
There is a file having column "AREA_CODE" which has values like
US929ABC
US12GH123
USA99CBH09
US999

I need to incorporate the below algorithm using DataStage functions on this column values- Check needs to be applied on 3rd,4th and 5th character..as given below

If AREA_CODE LIKE 'US[0-9][0-9][0-9]' Then "OK"
If AREA_CODE LIKE 'US[A-Z][0-9][0-9]' Then "OK"

Please advice how do we achieve this in DataStage Server jobs [7.1 edition]

Thanks,




Regards,
Suresh
Regards
DSExplorer
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

If Num(AREA_CODE[3,3]) = 1 Then 'OK' Else 'Not OK'
You are the creator of your destiny - Swami Vivekananda
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm sure Ray will suggest using matches, hopefully this syntax is correct as I don't use it much:

Code: Select all

Link.AREA_CODE Matches "'US'3N"
I'm assuming you can't just substring out positions 3-5 and check for numeric as "US999ABC" would pass muster but would in fact be invalid.
-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 »

Craig is right, and you can do all the matches using a multi-valued second argument. Put the pattern in a stage variable for ease of maintenance.

Code: Select all

svAreaCodePattern  <--  "'US'3N" : @VM : "'US'1A2N"

Link.AREA_CODE Matches svAreaCodePattern
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