× 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 have a program that loops through fetching various groups of records... This is within a statement that was called 3 times with different cursors.

The first time through, 4 rows were retrieved.
Second time, 1 row.
Third time, 1 row.

When this ran today, iteration 2 and 3 contained the new row AND the 3 rows leftover from the first iteration.

My question is, do I need to explicitly "clear" the data structure before the SQL Fetch?

I actually put that code in, recompiled, and ran the same process while in debug. But each time FetchGroup() was called, debug showed an empty REC data structure.
So I'm puzzled.

Code Snippet (after open cursor).

Dow FetchGroup(ach);
Do stuff here
Enddo;

Close cursor...


dcl-proc FetchGroup;

dcl-pi FetchGroup ind;
rec likeds(ach) dim(100);
end-pi;

dcl-s sqlRows int(10);
dcl-s maxrows int(10) inz(%elem(rec));


Exec Sql
Fetch Next From sqlcsr For :maxrows Rows
Into :rec;

if SqlStt <> sqlOK;
Exec Sql Get Diagnostics Condition 1
:sqlMsgID = DB2_MESSAGE_ID,
:sqlMsgText = MESSAGE_TEXT;
return *off;
endif;

return *on;

end-proc;
[Logo]<https://www.totalbizfulfillment.com/> Greg Wilburn
Director of IT
301.895.3792 ext. 1231
301.895.3895 direct
gwilburn@xxxxxxxxxxxxxxxxxxxxxxx<mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx>
1 Corporate Dr
Grantsville, MD 21536
www.totalbizfulfillment.com<http://www.totalbizfulfillment.com>

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.