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



On 23-Mar-2012 00:07 , Mike Bardin wrote:
On Wed, 21 Mar 2012 19:26:18 -0400
Vinay Gavankar <vinaygav@xxxxxxxxx> wrote:

<<SNIP>> _RLocate to get the RRN of a record based on a key from a
keyed logical file.

I wanted to get the total number of records in that file which have
Key equal to a particular value. <<SNIP>>


/*
variables: filePointer, keyValue,keyLength,recordCount
*/

recordCount=0;
_Rlocate(filePointer,NULL,0,__START);
while
((_Rlocate(filePointer,&keyValue,keyLength,__KEY_EQ))->num_bytes)
recordCount++;

Shouldn't that be __KEY_EQ first, then looping on __KEY_NEXTEQ [with the keyValue being ignored] to effect the increment of the recordCount beyond the first [if a __KEY_EQ was found]? Would not the looping using the __KEY_EQ request, loop indefinitely finding the same [the first] record with the specified key value; or at least loop until all the rows with the specified key value have since been deleted? The doc suggest that the "__KEY_EQ Positions to the first record with the specified key" from which I infer the same row would be read repeatedly, without having changed the keyValue [or keyLength].?

_i* ILE C/C++ Run-Time Library Functions *i_
_i _Rlocate() -- Position a Record i_
http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/rzan5mst217.htm
"...
__KEY_NEXTEQ
Positions to the next record that has a key equal to the key value with a length of klen_rrn, at the current position. The key parameter is ignored.
...
"

Also, what value would there be, in first obtaining a position of *START; i.e. seems unnecessary?

Regards, Chuck

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.