@Baldur:
im Eingangsposting stand:
Datei immer noch gesperrt und steht auf *EXCLRD bzw. *EXCL
und das ist m. E. keine Folge eines offenen Cursors und auf das EXCLRD bzw. EXCL bezieht sich die Bezeichnung Bug.

@All:
Cursor gehören bei sauberer Programmierung immer mit CLOSE cursorname geschlossen; bzw. noch einfacher ist es mit Commitment Controll, da schließt ein Commit (ohne hold, versteht sich) alle offenen Ressourcen.

Zum Close ist allgemein noch zu ergänzen: jeder close in SQL ist ein lazy close, d.h. die SQL Engine wird den ODP im allgemeinen offen halten!!!

Die Einstellung CLOSSQLCSR sorgt lediglich dafür, dass eine SQL close Operation auf den Cursor gemacht wird, garantiert aber keineswegs ein schließen des ODP.

Zu set option ist noch zu ergänzen: das ist eine Compiletime Anweisung, die immer nur für das erste SQL Programm/SRVPgm der Activation Group Auswirkungen hat (nebenbei bemerkt: fast unübersehbar, was zuerst aktiviert wird!!!).

Tatsächlich sicher freigegeben werden die SQL Ressourcen beim ENDJOB und bei OPM/ILE Programmen, die per SQL auf die lokale Datenbank zugreifen beim disconnect; bei Cleint Server Programmen nicht einmal dann. Wenn das stört, weil zum Beispiel ein anderes Programm ein RGZPFM, oder ähnliches machen will (sowas soll es ja auch noch geben), dann kann man mit ALCOBJ CONFLICT(*RQSRLS) von aussen die Freigabe einleiten.

mfg

Dieter Bender

Zitat Zitat von Fuerchau
Naja, ganz so ist es leider nicht.
SQL hält einen Insert-Cursor automatisch geöffnet (ODP), da ja noch ein 2. Insert folgen könnte und somit SQL diverse Routinen (Open, Prepare, Field- und Type-Check usw.) spart.
Das ist auch kein Bug (@Dieter) sondern vom Optimizer so gewollt.
Es gibt noch die Option, wann ein Cursor geschlossen werden soll:

set option closqlcsr=*endmod

Wenn das Modul beendet ist, werden alle SQL-Statements freigegeben und ODP's geschlossen (Default = *endjob):

CLOSQLCSR
Specifies when SQL cursors are implicitly closed, SQL prepared statements are implicitly discarded,
and LOCK TABLE locks are released. SQL cursors are explicitly closed when you issue the CLOSE,
COMMIT, or ROLLBACK (without HOLD) SQL statements. This option will be ignored in REXX.
*ENDACTGRP and *ENDMOD are for use by ILE programs and modules. *ENDPGM, *ENDSQL, and
*ENDJOB are for use by non-ILE programs.
This option is not allowed in an SQL function, SQL procedure, or SQL trigger.
*ENDACTGRP
SQL cursors are closed, SQL prepared statements are implicitly discarded, and LOCK TABLE
locks are released when the activation group ends.
*ENDMOD
SQL cursors are closed and SQL prepared statements are implicitly discarded when the module is
exited. LOCK TABLE locks are released when the first SQL program on the call stack ends.
*ENDPGM
SQL cursors are closed and SQL prepared statements are discarded when the program ends.
LOCK TABLE locks are released when the first SQL program on the call stack ends.
*ENDSQL
SQL cursors remain open between calls and can be fetched without running another SQL OPEN.
One of the programs higher on the call stack must have run at least one SQL statement. SQL
cursors are closed, SQL prepared statements are discarded, and LOCK TABLE locks are released
when the first SQL program on the call stack ends. If *ENDSQL is specified for a program that is
the first SQL program called (the first SQL program on the call stack), the program is treated as if
*ENDPGM was specified.
*ENDJOB
SQL cursors remain open between calls and can be fetched without running another SQL OPEN.
The programs higher on the call stack do not need to have run SQL statements. SQL cursors are
left open, SQL prepared statements are preserved, and LOCK TABLE locks are held when the first
SQL program on the call stack ends. SQL cursors are closed, SQL prepared statements are
discarded, and LOCK TABLE locks are released when the job ends.