Midrange News for the IBM i Community


Posted by: John Dowling
setll, read and update
has no ratings.
Published: 22 Oct 2013
Revised: 24 Oct 2013 - 1429 days ago
Last viewed on: 22 Sep 2017 (2811 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

setll, read and update Published by: John Dowling on 22 Oct 2013 view comments(6)

I'm missing something.   I have a program the setll, reads, updates and then reads gain.  It looks like it's reading the updated record again.  This what I'm dong

Setll *loval file

Read File

dow not %eof (file)

some processing here

Update file

Read file

enddo   (end of file)

Like I said it is reading thefile just updated.  Do I have to reset myself back into the file after the update ? 

 

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: Viking
Premium member *
CA
Comment on: setll, read and update
Posted: 3 years 11 months 1 days 1 hours 20 minutes ago
Edited: Tue, 22 Oct, 2013 at 18:00:24 (1431 days ago)

In your update, is the File keyed and are you updating the key fields?  Could it be that you put it back with a new key which places the record later in the keyed order and therefore it subsequently gets read again?

Posted by: Ringer
Premium member *
Comment on: setll, read and update
Posted: 3 years 11 months 1 days 32 minutes ago

Yes, if you are updating a KEY field and READing by Key, that record could magically reappear. 

What does your F-Spec look like? Is the K there or blank? 

Chris Ringer 

Posted by: john-d1
Premium member *
Comment on: setll, read and update
Posted: 3 years 11 months 23 hours 28 minutes ago
Edited: Tue, 22 Oct, 2013 at 19:58:00 (1431 days ago)

Yes the fields are part of the key, (item number) and I am changing it (addiding a suffix ie was A105 iow is A105-240).  How can I get around it ?

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: setll, read and update
Posted: 3 years 11 months 23 hours 27 minutes ago

Rember that the legacy *LOVAL is not usually what you want when doing a SETLL.

Typically you'll want to use *START

SETLL  *START  myfile;

 

Posted by: DaleB
Premium member *
Reading, PA
Comment on: setll, read and update
Posted: 3 years 11 months 22 hours 33 minutes ago

Do you have to have the file keyed? You're SetLL and ReadE are both sequential. If you remove the K from the F-spec, and just read sequential, you'll still read the entire file, but you'll only get each record once.

Posted by: john-d1
Premium member *
Comment on: setll, read and update
Posted: 3 years 10 months 29 days 4 hours 42 minutes ago

Thanks for all your comments.