Data Validation

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
shiva459
Premium Member
Premium Member
Posts: 100
Joined: Wed Jun 11, 2003 1:49 am
Location: Bangalore

Data Validation

Post by shiva459 »

Hi

we have a situation where we need to validate the identification number we are getting from the source.The number is 17 characters in length and may contain alphanumeric characters.Now the number can have alphabets A-Z and 0-9 excluding I,O,Q.It should not contain any special characters like *,/.etc etc.
Can anyone provide me insight how this can be acheived via a routine or other means.The source is a flatfile.
Any help in this regard would be appreciated.

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Shiva,

the built-in functions cannot handle this request directly, you would need to a short function yourself to do this.

Code: Select all

CleanIdentificationNumber(InString)

{for each character in the string}
   {if < '0' or > 'Z' then remove}
   {if I, O or Q then remove}
{next character}
If you look at the ASCII chart you will see that your legal character set does begin with the 0 and ends with a capital Z so it makes your job much easier. If you have trouble writing a function from this rough pseudocode outline then don't hesitate to post your code and you'll get assistance in this thread.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Try the following

Code: Select all

Convert(IConv(IConv(InpString, "MC/N"), "MC/A"): "IOQ", "", InpString)
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You need to check whether the case of alphabetic chars matter. If it does, you need to change the command a little.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

How about the following, which returns 0 for a valid string and a non-zero value otherwise?

Code: Select all

Len(TheString) <> 17 Or Len(Convert("ABCDEFGHJKLMNPRSTUVWXYZ0123456789","",TheString))
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
shiva459
Premium Member
Premium Member
Posts: 100
Joined: Wed Jun 11, 2003 1:49 am
Location: Bangalore

Post by shiva459 »

Thanks for all your responses.
I am going with Ray's advice as it is much simple to implement.

Thanks once again to everyone.
Post Reply