I have the SQLRPGLE code below showing my access and close – yet after the program runs the files (MONEWAS3 and WELFARE) stay open as verified by looking at “Display Open Files” for the session. If I sign off and sign back on they obviously close, but running the program again will open and leave them open.
When I compile the code (CRTSQLRPGI) I am changing CLOSQLCSR to *ENDMOD.
Any ideas as to what I am doing wrong that is causing the files to remain open?
ctl-opt dftactgrp(*no);
dcl-f MOCL0700DP printer oflind(PageOverflow) ;
dcl-s PageOverflow ind;
dcl-s count uns(10);
dcl-s inFund zoned(4);
dcl-s inDateRec zoned(8);
dcl-s inFedId packed(9:0);
dcl-s inPayPer zoned(8);
dcl-s inLname char(20);
dcl-s inFinit char(1);
dcl-s inMinit char(1);
dcl-s inSocSec packed (9:0);
dcl-s inAreaW zoned(4);
dcl-s inHomeW zoned(4);
nextPage();
exec sql create alias qtemp.monewas3a FOR MONEWAS3(AS30700);
exec sql declare C0 cursor for
SELECT ALL T01.FUND, T01.DATREC, T01.FEDID, T01.PAYPER, T01.LNAME,
T01.FINIT, T01.MINIT, T01.SOCSEC, T02.AREAW, T02.HOMEW
FROM monewas3a T01
INNER JOIN WELFARE T02 ON T01.SOCSEC = T02.SOCSEC
WHERE FUND = AREAW AND HOMEW <> 0322
ORDER BY T01.DATREC ASC, T01.FEDID ASC, T01.PAYPER ASC,
T01.LNAME ASC;
exec sql open C0;
dow (1=1);
exec sql fetch next from C0 into :inFund, :inDatRec, :inFedId,
:inPayPer, :inLname, :inFinit, :inMinit, :inSocSec, inAreaW,
:inHomeW;
if sqlcod <> 0;
leave;
endif;
if Pageoverflow;
nextPage();
endif;
write DETAIL;
count += 1;
enddo;
exec sql close C0 ;
exec sql drop alias qtemp.monewas3a;
if count = 0;
write ERR01;
endif;
*inlr = *on;
close *all;
dcl-proc nextPage;
pageoverflow = *off;
write HDG01;
end-proc;