Home » Other » General » OCI and threads
OCI and threads [message #103449] Tue, 07 October 2003 00:49 Go to next message
ulysses_dallas
Messages: 1
Registered: October 2003
Junior Member
I'm trying to implement a fairly straightforward multi-threaded app using OCI; however, the documentation in the OCI developer's guide is not clear about concerns I have.

This is for Oracle9i (9.0.1) on a Solaris 8 client.

The app is multi-threaded with up to 48 threads and is already functioning; however, I'm having to add Oracle database support at the last minute. It is a simple SELECT query and nothing more which the threads will have to perform when certain criteria are met, so they're not all constantly hammering the database.

My problem is this: all the OCI Thread examples show the threads being created/destroyed with OCI calls and I do not care to rewrite what is already working (don't really have the time either). I'm using pthread's in Solaris to create the threads.

What I would like to do is create the OCI environment with OCI_THREADED during initialization, create the threads and then simply have each thread login, do its query and exit each time they are required. On top of this, via OCI_THREADED, I'd like to allow OCI to manage the mutexes as the documentation states it will do this.

Is this feasible and are there any pitfalls I should be aware of by doing this? Must I use the OCI thread creation functions for the mutexing to function properly or is OCI smart enough to keep track of the threads on its own whenever someone makes a statement call using the single environment handle created at initialization? Given the low-level calls that OCI seems to use, it seems as if I'd have to do a lot of hand-holding and I don't care to make this already complex code anymore complex given all I need to do is make an occasional simple SELECT query.

If you know of any good OCI threaded examples, that would also be a huge help as I'm on a tight timetable and this is my first experience with OCI. I would do embedded SQL, but the app needs to be as fast as possible and OCI has other benefits that fit well with this project.

Thanks in advance,
-ulysses_dallas
Re: OCI and threads [message #103647 is a reply to message #103449] Wed, 11 February 2004 03:45 Go to previous message
Kenneth Freidank
Messages: 1
Registered: February 2004
Junior Member
I am doing the same, using OCI's Array Interface with pthreads on Solaris. I am having problems. The OCI gets set up once with OCIInitialize, and each thread gets its own environment handle using OCIEnvInit set to OCI_DEFAULT and subsequent connection. The blocks of memory with data to upload are intact while the thread is executing the bind statements to send to the database, I print them out. However, when I look at the database when all is said and done, many of the records are incomplete, i.e. only the first or sometimes 1st and 2nd column of the array makes it to the database, all the other fields are null. Have you seen this behaviour??
Previous Topic: DATA BASE LINK (Fatal Two-Task Communication Protocol Error, Oracle 8i)
Next Topic: Oracle 9i tuning self test wanted
Goto Forum:
  


Current Time: Sat Nov 30 03:46:10 CST 2024