Q
Problem solve Get help with specific problems with your technologies, process and projects.

Skipping a record when doing a sequential read

If I am doing a sequential read, end up with a locking condition, how would I be able to simply skip that record, and go to the next one in the sequence. At the point the record locks, I do NOT have the key info, so I can not do a SETGT to that record. For this particular program, we simply sent up a message, and ended the job, but I would like to continue and process non-locked records.


Simply do a read with an error indicator, the low indicator in RPG, or an (E) extender in RPGLE. If the read fails with the error indicator *On and the EOF indicator *Off, or %Error is true in RPGLE, you can get the error without terminating your program. You can either get fancy with a *PSSR routine or %STATUS keyword in RPGLE to verify the condition that caused the error, or simply do an additional read with a "No Lock" indicator. If that read is successful, then the error was a record lock. If your records are not marked with a flag or timestamp for this program processing the record, store the key for later use. Read the next record and continue processing. When you are at EOF, you can go back to your stored records to attempt to process them again. I would simply do a read with the error indicator and an additional read with the "No Lock", store the record and continue.


Dig Deeper on RPG iSeries programming

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close