Validate data based on Conditions at runtime
Moderators: chulett, rschirm, roy
Validate data based on Conditions at runtime
Hi All,
we have a req to validate an input file with following format
amount condtion
100 (amount>=0 and amount<=300)
200 (amount>=5 and amount<=800)
300 (amount>=0 and amount<=300)
As the above as input source file, we need to validate the amount(field1) based on the condtion(field2).
Please help me out to do this. This is an urgent req.
Thanks in advance,
shyju
we have a req to validate an input file with following format
amount condtion
100 (amount>=0 and amount<=300)
200 (amount>=5 and amount<=800)
300 (amount>=0 and amount<=300)
As the above as input source file, we need to validate the amount(field1) based on the condtion(field2).
Please help me out to do this. This is an urgent req.
Thanks in advance,
shyju
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
We don't do "urgent" here. If you need urgent assistance sign up with your support provider for premium service, and learn the true cost of urgent. This is an all-volunteer site, on which people post as and when they can.
I think you will need to create a routine to effect this validation; validation within the tool needs to use fixed expressions not variable ones. The result of the routine would probably be 0 (success) or 1 (failure) or, if you prefer the DataStage convention, 1 (true) or 0 (false).
I think you will need to create a routine to effect this validation; validation within the tool needs to use fixed expressions not variable ones. The result of the routine would probably be 0 (success) or 1 (failure) or, if you prefer the DataStage convention, 1 (true) or 0 (false).
Code: Select all
FUNCTION CheckRange(LineFromFile)
* This routine assumes an inclusive range check with integer values.
ValueToCheck = Field(LineFromFile, " ", 1, 1)
Condition = LineFromFile[Col2(),Len(LineFromFile)]
LowerLimit = MatchField(Condition,"0X0N0X0N0X",2)
UpperLimit = MatchField(Condition,"0X0N0X0N0X",4)
Ans = (ValueToCheck >= LowerLimit) And (ValueToCheck <= UpperLimit)
RETURN(Ans)
Last edited by ray.wurlod on Mon Dec 17, 2007 5:26 pm, edited 1 time in total.
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Accepted. If you had premium membership you would see that I posted a suggested solution function. It's a worthwhile investment, and helps to fund the hosting and bandwidth costs needed to keep DSXchange alive.
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.
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
Is your column fields a varchar? And are these((amount>=0 and amount<=300)) the actual values you would expect? are these only a finite set of values?100 (amount>=0 and amount<=300)
200 (amount>=5 and amount<=800)
300 (amount>=0 and amount<=300)
You can do this using a BASIC routine, which accepts the amount and condition fields and returns you a boolean value which tells you if it is valid or not.
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
Please answer the questions for a more specific answer ![Wink ;)](./images/smilies/icon_wink.gif)
![Wink ;)](./images/smilies/icon_wink.gif)
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
The problem with your logic may be because when you do an Ereplace. It treats the whole thing as a string... So the value of your "expr" would have been "20< 100 and 20>1" (Assuming Amount:20 and condition: A<100 and A>1) which would be a STRING if I am not wrong.
What you need here is to find the actual *computed* value...
Try parsing your condition and formulating your expressions rather than doing an Ereplace....
What you need here is to find the actual *computed* value...
Try parsing your condition and formulating your expressions rather than doing an Ereplace....
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>