Problem solve Get help with specific problems with your technologies, process and projects.

Close cursors when SQL is embedded

This tip shows you how to close any open cursors in your program.

When you have embedded SQL in RPGLE programs, use default activation group *no and use cursors to read through...

your data, it is not enough to close any open cursors in your program. The default compile option on the CRTSQLRPGI command for Close SQL cursor is *ENDACTGRP (end activation group). When I used dftactgrp(*no) and was running in the QILE activation group my files remained open after the programs were done running because QILE was never ended. You must change the compile option for Close SQL cursor to *ENDMOD (end module) then all open cursors are closed when the module ends.


The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

Dig Deeper on iSeries CL programming