Scott, the only thing is the Status code is not part of the key.
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Tuesday, September 11, 2007 12:49 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Read question
Phil Kestenbaum wrote:
What actually happens when the status is changed? Is the program still
going to read the original records anyway? I would think not but
wanted
to check.
If I understand you correctly you're doing something like this:
setll ('A') MYLOGICAL;
READ MYLOGICAL;
dow not %EOF and status='A';
status = 'H';
UPDATE MYLOGICALRECFMT;
READ MYLOGICAL;
enddo;
Is that correct? What happens when the status is changed? Err, well,
when you run the READ op-code, the contents of the status field are
copied from the database to a field in your program's memory. When you
change the status field to an H, you change that memory to be an H.
When you run the UPDATE op-code, it moves the field from memory back to
the database file, causing the field to change in the file.
When you read the next record, it reads the next record with an 'A' that
occurs after the last one you read.
Is the program still going to read the "original records"? I don't know
what you mean by "original". Do you mean all of the records marked with
an "A"? Yes, it'll read them all, unless a program adds some additional
"A" records while you're processing it. But, that's what your code
was supposed to do, right? Read all of the records that contain an "A"?
That's why I'm confused by your question... You don't think it's
going to read them all, and I don't understand why not...?? You coded
it to read them all! Then I find myself thinking, maybe when he said
"original", he didn't mean status code A? But... the program is coded
to read in key sequence based on the A, so it shouldn't read anything
that's not status code A -- except on the last READ statement, when it
sees a non-A record, and terminates the loop...
So I guess I really don't understand what you're asking.
As an Amazon Associate we earn from qualifying purchases.