Understanding SQL Objects and Application Engine Programs
A global variable won’t go out of scope until a Application Engine program finishes. However, all SQL objects are forced closed (that is, the cursor closed) sooner than that. Any open SQL object is forced closed just before any checkpoint in an Application Engine program.This is to ensure that the application can be restarted successfully from the checkpoint. After the SQL object is closed, you can reopen the SQL object, or query its properties, (such as Status, IsOpen). The simplest way to avoid unnecessary closing of the SQL object is to set the ReuseCursor property to True. A restartable program should always check that SQL objects are open before using them in steps where it's expected they're open. In the absence of an intervening checkpoint, an open SQL object remains open until the Application Engine program finishes.