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.

==================================
MORE INFORMATION ON THIS TOPIC
==================================

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.


This was first published in August 2002

Dig deeper on iSeries CL programming

1 comment

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchEnterpriseLinux

SearchDataCenter

Close