× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I'll take a look at that, Javier, interesting to think about. I also want to think about optimization of repeated use of the same statement - I think I'm saying it right!

Cheers
Vern

On 3/9/2023 11:17 AM, Javier Sanchez wrote:
Vernon,

When you use that approach, you actually make the precompiler generate
twice the call to the fetch with a different set of variables, different
from the ones it created for the initial fetch. Not that is a bad thing,
but only a waste of resources. Of course the speed of execution is so fast
that it may not be a performance issue.

I always use this approach:

declare the cursor;
open the cursor;
enter a dow loop anyway;
fetch;
check for a positive fetch;
if positive;
do your task;
else;
leave the loop;
close the cursor;

When you stare at the actual RPG code generated you will see only one place
where the fetch is invoked and only one set of variables for the "into" is
seen.

With your approach (again it's not bad) you will see two sets of "into"
variables generated.

WADR.

Javier.

El jue, 9 mar 2023 a las 10:31, VERNON HAMBERG Owner via MIDRANGE-L (<
midrange-l@xxxxxxxxxxxxxxxxxx>) escribió:

Hello Sergio


Not every SQLCODE other than 0 or 100 is an error - only those < 0 are
hard errors. I was told to do something like this - I prefer a first Fetch,
then the Dow loop with a Fetch before the EndDo - I know, this is a
religious choice, so I will not discuss it!!


exec sql
fetch ...;


dow sqlcode >= 0 and sqlcode <> 100;
...;
...;


exec sql
fetch ...;
enddo;


Positive SQLCODE are often about something that makes the statement less
efficient - 12 (unqualified correlation) or 30 (# of host variables
different from # of result values) might not be a problem, they are just an
indication of sloppy coding practice.


Cheers
Vern


On Thu, 9 Mar, 2023 at 4:39 AM, Sergio Luis Puentes-Valladares <
spuentes@xxxxxxxxx> wrote:


To: midrange systems technical discussion

Hi Gerald
After all Fetch or Select, you must control the result of these operations,
using SQLCODE verification, through an IF, the value returned by SQLCODE =
0000, operation was performed correctly, in this case FETCH was able to
read a record or Select found what
I was looking for, SQLCODE = 0100, It means that the FETCH or SELECT
operation did not find anything, any other value is ERROR
Regards

Sergio L Puentes Valladares
IT Developer SR IBM i RPG/COBOL
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:
MIDRANGE-L@xxxxxxxxxxxxxxxxxx>
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:
MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx>
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:
support@xxxxxxxxxxxxxxxxxxxx> for any subscription related questions.

.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.