View previous topic :: View next topic
|
Author |
Message |
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
Hi,
Is there a way I can do a SEARCH ALL whereby the search continues after a match ? If there is more than one match I want to perform one set of instructions but if there is only one match, another set of instructions.
Thanks,
J. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi J,
I don't believe so.
In fact, one of the requirements for a successful "SEARCH ALL" is that the items be unique.
From the Fine Manual:
Quote: |
The results of a SEARCH ALL operation are predictable only when:
The data in the table is ordered in ASCENDING/DESCENDING KEY order
The contents of the ASCENDING/DESCENDING keys specified in the WHEN clause provide a unique table reference. |
Which says that if you do not have unique items, you may get a wrong answer.
To do what you want, i'd suggest starting at the beginning and if the table value goes greater that your argument value, it is a no-hit. If you "hit" once, increment to the next and see if they are equal. If so, you have your multiple case - if not it is the single hit case. For this, the table soule also need to be in sequence. |
|
Back to top |
|
|
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
Thanks Dick. I decided to do a PERFORM...VARYING instead and am in the process of testing that.
Thanks,
J. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome
We're here if you have any new "opportunities". . . |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
I have seen a program do a SEARCH ALL and then continue with a small sequential search. The data in the table looked like this: Sample data:
Emp Effective Expiry Salary
Joe 2001-01-01 2003-09-23 $40,000
Joe 2003-09-23 9999-12-31 $42,000
I recall that once the SEARCH ALL found a match on Joe, it would follow up with a sequential search (it would search forward and backward as needed) - the purpose of the additional sequential search was to find the row that was currently effective. |
|
Back to top |
|
|
livingston
New User
Joined: 20 Feb 2007 Posts: 6 Location: India
|
|
|
|
hi
we cannot find more than one matches using SEARCH ALL. For doing so you can go for PERFORM UNTIL.... |
|
Back to top |
|
|
|