As requested by Gordon den Otter, return a boolean from connection.prepare()

indicating whether or not a transaction has been prepared for commit so that
the error ORA-24756 (transaction does not exist) can be avoided.
This commit is contained in:
Anthony Tuininga 2008-12-08 19:51:18 +00:00
parent 15cbc242cb
commit bd5915a435

View File

@ -1322,10 +1322,17 @@ static PyObject *Connection_Prepare(
if (Environment_CheckForError(self->environment, status,
"Connection_Prepare()") < 0)
return NULL;
self->commitMode = OCI_TRANS_TWOPHASE;
Py_INCREF(Py_None);
return Py_None;
// if nothing available to prepare, return False in order to allow for
// avoiding the call to commit() which will fail with ORA-24756
// (transaction does not exist)
if (status == OCI_SUCCESS_WITH_INFO) {
Py_INCREF(Py_False);
return Py_False;
}
self->commitMode = OCI_TRANS_TWOPHASE;
Py_INCREF(Py_True);
return Py_True;
}