Validate data based on Conditions at runtime

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
shyju
Participant
Posts: 58
Joined: Thu May 19, 2005 1:00 am

Validate data based on Conditions at runtime

Post by shyju »

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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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).

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.
shyju
Participant
Posts: 58
Joined: Thu May 19, 2005 1:00 am

Post by shyju »

I apologise for that.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

100 (amount>=0 and amount<=300)
200 (amount>=5 and amount<=800)
300 (amount>=0 and amount<=300)
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?

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>
shyju
Participant
Posts: 58
Joined: Thu May 19, 2005 1:00 am

Post by shyju »

what i understood is
take the amount and condtion as input parameter..
then do the validaion as return the boolean to the calling job.

How do we validate the amount with a condtion created at run time?


Thanks for you response.
Shyju
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

Please answer the questions for a more specific answer ;)
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>
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... or get premium membership to see solution already provided.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
shyju
Participant
Posts: 58
Joined: Thu May 19, 2005 1:00 am

Post by shyju »

Logic for Routine we wrote is:

1)Take the condtion(A<100 and A>1) and amnt as input parameter.
2)expr = Ereplace(condtion,field,amnt)
3)If expr then Ans=true else Ans=false

But the routine didn't return result as expected.

The 3rd stmt is not working.

Please advise me on this.

Thanks,
Shyju
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

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....
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>
Post Reply