Hi All,
I have a requirement in my current project to do a validation check on a key column. The column is the account key which is a 12 digit integer.
The business requirements are to check the column for the following constraints and if it fails in any one of the constraints, then the record is to be sent to the reject file.
1. If the length is less than 12 digits for e.g., 123456789 instead of 000123456789.
2. If the value has blank fields in it like "00 123456789"
3. If the value has alphabets and/or special characters in it like "0$01_3d567c9"
Can these checks be done using Datastage? I have Qualitystage and Information Analyzer also in the project. So please tell if it is doable by these softwares also.
Thanks in advance.
Data Validation Criteria
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 138
- Joined: Wed Jul 16, 2008 9:51 pm
- Location: Kolkata
An integer is an integer so a check to ensure there are 'enough leading zeroes' doesn't really make much sense as they don't have them. Or is this coming in as a string? I would guess so based on your other criteria.
Look into the IsValid() and Length() functions... the latter could be Len(), don't recall. They should get you well on your way.
![Confused :?](./images/smilies/icon_confused.gif)
Look into the IsValid() and Length() functions... the latter could be Len(), don't recall. They should get you well on your way.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 138
- Joined: Wed Jul 16, 2008 9:51 pm
- Location: Kolkata
That makes more sense if you need to check that all 12 significant digits are 'used', so to speak. Again, assuming this is coming in as a string, there's also a game you can play with the Convert() function - strip out all valid values and if the original value was valid nothing should be left. Leftovers = invalid:
![Wink :wink:](./images/smilies/icon_wink.gif)
Some combination of those should cover your scenarios, I would think. Or you could go all Old School on it and after getting a good conversion from StringToDecimal() check the value is in an appropriate range: 100000000000 to 999999999999 if I've banged in all the digits correctly.If Convert("0123456789","",Link.YourField) = "" Then "valid" else "invalid"
![Wink :wink:](./images/smilies/icon_wink.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
DataStage can do all this in one expression although, for ease of maintenance, you may like to break it up into stage variables.
Code: Select all
Len(InLink.The String) <> 12 Or Index(InLink.TheString, " ", 1) > 0 Or Len(Convert("0123456789","",InLink.TheString)) <> 0
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 138
- Joined: Wed Jul 16, 2008 9:51 pm
- Location: Kolkata