Page 1 of 1

How to check for numeric characters field by field

Posted: Fri Apr 23, 2010 12:36 pm
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

Posted: Fri Apr 23, 2010 12:49 pm
by anbu
If Num(AREA_CODE[3,3]) = 1 Then 'OK' Else 'Not OK'

Posted: Fri Apr 23, 2010 1:53 pm
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.

Posted: Fri Apr 23, 2010 4:38 pm
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