|
Hi Richard, If you do not want to use embedded SQL because it is too slow, why not externalizing the function Next_Eid into a separate module (or better service program)? Within a separate module, you don't have to care about global or local. >>it ran about a third slower, but that >>seems acceptable at this time. May be it's even faster. The query optimizer needs at least two runs where it determines the optimal access path. After the second run it may reuse the Open Data Path (if it is resusable). To say something about performance, you have check the time that is used after the third run. But if you use CLOSQLCSR = *ENDMOD, the optimizer will determine the optimal access path with each run and cannot use an open data path. After executing the module a hard close is performed. The same thing happens if dynamic SQL is used. Birgitta -----Ursprüngliche Nachricht----- Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]Im Auftrag von Rich Duzenbury Gesendet: Donnerstag, 8. Dezember 2005 03:03 An: RPG programming on the AS400 / iSeries Betreff: RE: RNF7701 - Data structure not allowed . On Wed, 2005-12-07 at 15:48 -0600, Holden Tommy wrote: > Here's how I would handle this.. > > p next_eid b > d next_eid pi 11s 0 > > d result s 11s 0 > > c/exec sql > c+ Select Max(EID) into :result from wmerlgp > c/end-exec > /free > if SQLSTT='02000'; > result = 1; > else; > result += 1; > endif; > return result; > /end-free > p e > Thanks Tommy. So far, it's the only _working_ candidate. I ran it against a simple setgt/readp, and for 10K records, it ran about a third slower, but that seems acceptable at this time. According to debug, it does use the index to find the value, so it should not get appreciably slower as the file gets larger. Regards, Rich -- 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-2025 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.