This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
7 Responses
I incorporated this example into my blog https://rpgfreeibm.blogspot.com/2024/01/sqlcode-values-dear-readers-unleash.html because I find it highly insightful. I’m open to any modifications if needed. Special thanks to the authors of the referenced page for providing such a valuable resource.
Thank you Aldo!
Hi Antonio,
How about declaring nRows as dim( %elem( employee ));
to get rid of the hardcoded value of 5.
All the best,
Stefan
Hi Stefan,
very good advice. I change it.
Thank you!
If you’re displaying all of the records, I don’t see the benefit of retrieving 5 rows at a time. Why not 100?
For a more practical use, this is good for a subfile when displaying one page at a time.. If the subfile page holds 15 employees, you retrieve “for 15 rows” and exfmt the subfile.
For the display file, it is expected to display More or Bottom depending if there is more data or not. How would you handle this?
Hi Glenn,
retrieve only 5 rows at a time is just an example. Of course in a “real” program the number can be greater but for educational purposes I retrieve only 5. There are only 13 records in my database file and I wanted to show how GET DIAGNOSTICS works retrieving 5, 5 and 3 records. But even retrieving only 5 rows at a time is more efficient than doing it one at a time. Think of a fetch as a request to the database to send you a message containing lines. Every time you run a fetch, the database responds with a message with the lines you requested. If you retrieve 5 rows one by one, the database sends you 5 messages, one per line, but if you retrieve 5 lines at a time it only sends one, so you save 4 messages, which leads to better performance . After all, it is about minimizing input-output operations.
Regarding to your question you can read one more row and check EOF to set SFLEND indicator or not and reposition the cursor in case EOF is false. I’m preparing another post about SCROLL CURSORS and I think I can use a subfile and try this approach. So stay tuned.