Cursor scoping rules

The scope of a cursor declaration is the file in which it is declared. The open statement(s) for a cursor must reside in the same file in which the cursor is declared. Once a cursor is open, its scope is the connection on which it was opened.

The same cursor name can be opened for multiple connections. Cursor fetch, update, delete, and close operations can occur in files other than the one in which the cursor was declared, as long as they are executed on the same connection on which the cursor was opened.

Cursor names must be unique within a program. If, at runtime, an application attempts to declare two identically named cursors, the application fails with the following error message:

There is already another cursor with the name ‘XXX’.