Can I do this using one OCIEnv handle in multi-threaded application?
569143Sep 19 2007 — edited Sep 20 2007I create OCIEnv whit threaded parameter, then:
1. startup two threads in Windows XP, each one make a connection to same database using same OCIEnv, so I have two connection now. Then each thread query database to fetch very large recordsets, just like this:
OCIStmtPrepare2(...);
OCIStmtExecute(...);
while(...)
{
OCIStmtFetch2(...);
}
Two threads take much time to do this loop, they use different connection and different OCIStmt. I know OCIEnv has mutex for thread-safety, but when two threads run this loop at the same time, is it still safe?
2. If i use only one connection for two threads, do same opetion as above, is it still safe?
I think in any OCIXXXXX() function, OCI library can use mutex to make thread-safety, but I am not sure if consistency should be maintained in a series of OCI calls.
by the way, if I create one OCIEnv for one thread, I could create it without OCI_THREADED parameter? Is this would cause low performance?
Thanks very much!