installing cx_Oracle

David Fraser davidf at sjsoft.com
Fri Jun 4 16:11:06 EDT 2004


Rodrigo Daunaravicius wrote:
> According to the Oracle Docs, "OCIEnvCreate creates and initializes an
> environment for OCI functions to work under".
> 
> So my uneducated guess is that this OCIEnvCreate function is not present in
> Oracle 8.0.6, but I can't find anything in the docs that hints to it.
> 
> 
> 1. Is there a way around this OCIEnvCrete problem?

 From 
http://www.csee.umbc.edu/help/oracle8/server.815/a67846/oci_func.htm#543147
> OCIEnvCreate()
> 
> This call creates an environment for all the OCI calls using the modes specified by the user. This call should be invoked before any other OCI call and should be used instead of the OCIInitialize() and OCIEnvInit() calls. OCIInitialize() and OCIEnvInit() calls will be supported for backward compatibility.
> 

If you really need to get it working with 8.0.x libraries, you could try 
converting the call to OCIInitialize() and OCIEnvInit() calls.
You'll need to replace OCITerminate with OCIHandleFree.
In my experience these are the two main changes between 8.0.x and 8.1
You might find some help from the cx_Oracle authors, but the oracle docs 
are fairly good.
Here is some code from a C++ database class that supports either 
(tryimportOCIProc and importedOCIProc and importOCIProc are macros that 
do dynamic function resolving, you should get the general idea)

   tryimportOCIProc(OCIEnvCreate, sword, (OCIEnv **envp, ub4 mode, dvoid 
*ctxp,
     dvoid *(*malocfp)(dvoid *ctxp, size_t size),
     dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr, size_t newsize),
     void (*mfreefp)(dvoid *ctxp, dvoid *memptr),
     size_t xtramem_sz, dvoid **usrmempp));

   if (!importedOCIProc(OCIEnvCreate))
   {
     importOCIProc(OCIInitialize, sword, (ub4 mode, CONST dvoid *ctxp,
       CONST dvoid *(*malocfp)(dvoid *ctxp, size_t size),
       CONST dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr,size_t newsize),
       CONST void (*mfreefp)(dvoid *ctxp,dvoid *memptr)));
     importOCIProc(OCIEnvInit, sword, (OCIEnv **envhpp, ub4 mode,
       size_t xtramemsz, dvoid **usrmempp));

     if (envhp == 0)
     {
       OCIInitialize(OCI_THREADED, 0, 0, 0, 0);
       OCIEnvInit(&envhp, OCI_DEFAULT, 100, &testmem);
     }
     // AfxMessageBox("Using OCI 8.0",MB_OK);
   }
   else
   {
     if (envhp == 0)
     OCIEnvCreate(&envhp, OCI_THREADED, 0, 0, 0, 0, 0, 0);
   }



More information about the Python-list mailing list