|
Lim -You're correct about the pointer being lost, and I just wrote a quick test program to verify that when the CHAIN is NOT successful, the file fields retain whatever value was previously in them, so RPG doesn't clear them on an unsuccessful CHAIN.
However, as far as SETLL and performance, the following is straight from the V5R3 RPG Reference:
SETLL does not cause the system to access a data record. If you are only interested in verifying that a key actually exists, SETLL with an equal indicator (positions 75-76) or the %EQUAL built-in function is a better performing solution than the CHAIN operation in most cases. Under special cases of a multiple format logical file with sparse keys, CHAIN can be a faster solution than SETLL.
- sjl----- Original Message -----
From: "Lim Hock-Chai" <Lim.Hock-Chai@xxxxxxxxxxxxxxx> To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx> Sent: Wednesday, February 28, 2007 3:57 PM Subject: RE: CHAIN Versus SETLL and READ When Data Needed
Yes. If chain failed, the file pointer will be lost. I was replying about Steve's email regarding it clears the buffer if chain failed. I don't believe that is true. If chain failed, all data in the program remain the same, which is why I think using setll and then read will not have any performance gain. I think it will make it run slower (Not to mention ugly coding :)). -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Marvin Radding Sent: Wednesday, February 28, 2007 3:44 PM To: rpg400-l@xxxxxxxxxxxx Subject: RE: CHAIN Versus SETLL and READ When Data Neededmessage: 1 date: Wed, 28 Feb 2007 15:04:47 -0600 from: "Lim Hock-Chai" <Lim.Hock-Chai@xxxxxxxxxxxxxxx> subject: RE: CHAIN Versus SETLL and READ When Data Needed AFAIK, chain will not clear any data in the program when not found. With that say, I think chain is faster. Since setll and read require two trips. If chain is not found, it would be like setll.From the manual:When the CHAIN operation is successful, the file specified in name is positioned such that a subsequent read operation retrieves the record logically following or preceding the retrieved record. When the CHAIN operation is not completed successfully (for example, an error occurs or no record is found), the file specified in name must be repositioned (for example, by a CHAIN or SETLL operation) before a subsequent read operation can be done on that file. Just so no one is lead astray, if a CHAIN fails, the pointer is undefined and any read operation will results in an error. Marvin -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
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.