Page 1 of 1

Data Validation

Posted: Thu Jun 16, 2005 5:59 am
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

Posted: Thu Jun 16, 2005 6:06 am
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.

Posted: Thu Jun 16, 2005 6:27 am
by Sainath.Srinivasan
Try the following

Code: Select all

Convert(IConv(IConv(InpString, "MC/N"), "MC/A"): "IOQ", "", InpString)

Posted: Thu Jun 16, 2005 6:35 am
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.

Posted: Thu Jun 16, 2005 9:27 pm
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))

Posted: Sat Jun 18, 2005 4:40 am
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.