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



Establishing cursor position for keyed read [random I\O] is somewhat moot; keyedfile should have established position already, typically to *START, then the I\O with a key specified determine where to position and get the row. There seems no reason both to get random position and then to get random position with an I\O.? Ignoring the [then missing] try\catch, what about the changes inline below; i.e. use a request to read-first instead of positioning, then loop on read-next-equal? IIRC, that is how I would have coded to the equivalent MI methods to effect [what I infer is] the desired, as described and from the given source.

As for the use of unsigned, AFaIK the database has no support for unsigned numeric; not integer nor decimal types. A "large" unsigned provided as an input key could presumably select a negative value if the type mismatch was not diagnosed.?

Regards, Chuck

On 18 Oct 2012 18:17, Dan Kimmel wrote:
I'm using the following code to read all the records from one file
(fileVAL) with keys matching the key in another file (fileINF).
Occasionally, I'll get records from fileVal that are greater than
the search key. Not always. Most of the time, I'll get a null back
from the readNextEqual() when the next record in the file has a
higher value for the key. fileINF is set as unique(*yes) and fileVal
is set as unique(*no). The key is defined as eight characters long,
CCSID 37, collating sequence *HEX. The value is an ever incrementing
8-byte unsigned integer. Are there values where, perhaps when the low
order byte is somewhere in the hex 00 to hex 20 range, that
readNextEqual() will consider different values as equal?

fileINF.positionCursorBeforeFirst();
recordINF = fileINF.readNext();
if (recordINF != null) {
String result=null;
this.doAnother = !((String)(recordINF.getKeyFields()[0])).equals("**QUIT**");
if (doAnother){
this.doAnother=true;
Object[] keys = recordINF.getKeyFields();
String uniqueId = recordINF.getField(0).toString();
WorkpieceCreationInfo wpCreate = new WorkpieceCreationInfo(
recordINF.getField(1).toString().trim(),
recordINF.getField(2).toString().trim(),
recordINF.getField(3).toString().trim(),
recordINF.getField(4).toString().trim());
log.debug("FLOCWPINF read"+
"\n\t"+recordINF.getField(0).toString().trim()+
"\n\t"+recordINF.getField(1).toString().trim()+
"\n\t"+recordINF.getField(2).toString().trim()+
"\n\t"+recordINF.getField(3).toString().trim()+
"\n\t"+recordINF.getField(4).toString().trim());
{
Record recordVAL = null;
try {

// read first or fail to find key
recordVAL = fileVAL.read(keys);

do {
if (recordVAL != null) {
wpCreate.addValue(
recordVAL.getField(1).toString().trim(),
recordVAL.getField(2).toString().trim());
log.debug("FLOCWPVAL read"+
"\n\t"+recordVAL.getField(0).toString().trim()+
"\n\t"+recordVAL.getField(1).toString().trim()+
"\n\t"+recordVAL.getField(2).toString().trim());
}

// read next-equal or fail to find key
recordVAL = fileVAL.readNextEqual(keys);

} while (recordVAL != null);
} catch (AS400Exception e){
// nothing in the file for the key
}
}


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.