From bd5915a435dcf2ef17078793ee9d14e26a88f598 Mon Sep 17 00:00:00 2001 From: Anthony Tuininga Date: Mon, 8 Dec 2008 19:51:18 +0000 Subject: [PATCH] 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. --- Connection.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Connection.c b/Connection.c index 5e24ab0..d3cb83b 100644 --- a/Connection.c +++ b/Connection.c @@ -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; }