× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Did you ever heard about the %equal op code. This allows you the check a
setll operation without reading the record.
Just google it.

kf

-----Ursprüngliche Nachricht-----
Von: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] Im Auftrag von
James H. H. Lampert via RPG400-L
Gesendet: Freitag, 3. Juni 2022 19:38
An: RPG programming on the IBM i / System i
Cc: James H. H. Lampert
Betreff: Checking for existence of a record

Suppose I have a file that is keyed on a customer number and a date,
both keys ascending.

And I want to check for the *existence* of at least one record with the
specified customer number and a date *no earlier than* a specified
cutoff. The *contents* of that record are of no interest; all I care
about is the *existence* of at least one.

I have a KLIST on my file. I plug the customer number into the first
field of the KLIST, and the cutoff date into the second.

In my test program, I look for two different customer numbers, one which
*does* have at least one record meeting the cutoff date, and one which
*does not* have one.

If I SETLL on the KLIST, without actually reading anything, and only
looking at %FOUND, then both come back with %FOUND = true, since the
customer number *without* a record-of-interest just falls through to the
next customer number.

If I CHAIN on the KLIST, then they both come back with %FOUND = false,
since the customer number *with* a record-of-interest doesn't have one
that exactly matches the date.

I *could* do a READ after the SETLL, and check to see if the customer
number matches. Or I *could* do a READE on it, specifying only the
customer number, and check %EOF.

Is there anything else that I'm missing?

I'm looking for maximum efficiency on this check, as it's going to have
to be run for a few thousand different customer numbers.

--
JHHL

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.