When a connection is acquired from the pool the session handle is not directly

available so grab it from the main handle instead.
This commit is contained in:
Anthony Tuininga 2008-11-11 20:35:25 +00:00
parent f63f47639c
commit 98f928a819

View File

@ -364,23 +364,33 @@ static int Connection_SetOCIAttr(
PyObject *value, // value to set PyObject *value, // value to set
ub4 *attribute) // OCI attribute type ub4 *attribute) // OCI attribute type
{ {
OCISession *sessionHandle;
udt_StringBuffer buffer; udt_StringBuffer buffer;
sword status; sword status;
// verify arguments
if (!cxString_Check(value)) {
PyErr_SetString(PyExc_TypeError, "value must be a string");
return -1;
}
// make sure connection is connected // make sure connection is connected
if (Connection_IsConnected(self) < 0) if (Connection_IsConnected(self) < 0)
return -1; return -1;
// set the value in the OCI // acquire the session handle
if (!cxString_Check(value)) { status = OCIAttrGet(self->handle, OCI_HTYPE_SVCCTX,
PyErr_SetString(PyExc_TypeError, "value must be a string"); (dvoid**) &sessionHandle, 0, OCI_ATTR_SESSION,
self->environment->errorHandle);
if (Environment_CheckForError(self->environment, status,
"Connection_SetOCIAttr(): determine session handle") < 0)
return -1; return -1;
}
// set the value in the OCI
if (StringBuffer_Fill(&buffer, value)) if (StringBuffer_Fill(&buffer, value))
return -1; return -1;
status = OCIAttrSet(self->sessionHandle, OCI_HTYPE_SESSION, status = OCIAttrSet(sessionHandle, OCI_HTYPE_SESSION, (text*) buffer.ptr,
(text*) buffer.ptr, buffer.size, *attribute, buffer.size, *attribute, self->environment->errorHandle);
self->environment->errorHandle);
StringBuffer_Clear(&buffer); StringBuffer_Clear(&buffer);
if (Environment_CheckForError(self->environment, status, if (Environment_CheckForError(self->environment, status,
"Connection_SetOCIAttr()") < 0) "Connection_SetOCIAttr()") < 0)