Home » Developer & Programmer » Precompilers, OCI & OCCI » Multiple threads and multiple runtime contexts
Multiple threads and multiple runtime contexts [message #93952] Wed, 21 May 2003 11:12
Mike
Messages: 417
Registered: September 1998
Senior Member
Hello,

I have written a program using C and Pro*C which is "supposed" to do the following in mono and multithread mode :

- Read a line of data from an input file
- Perform inserts and updates in 2 Oracle tables using data from the input file line.

In monothread mode everything works fine, but once I switch to multithreading I'm getting very bizarre results.

I am using a different runtime context for each thread, with each context having a unique connection to the database. I read in the Oracle Pro*c documentation that this scenario works without the use of mutexes, since each context is independant of the others.

The problem is that I am systematically getting the following error when I execute the SQL for some of the input lines:

ORA-00001: violation de contrainte unique

Should I be using mutexes to protect data ? Is there a way that I can have multiple threads writing in the same table (by using row share mode) ?

I've already tried encapsulating everything to do with SQL in a mutex lock, and the application runs fine, but both database tables and locked for 1 thread, which equals a monothread application !

If you can help, thanks in advance.
Previous Topic: Diff B/W C and Pro*C
Next Topic: Pro*Cobol
Goto Forum:
  


Current Time: Wed Apr 24 10:47:43 CDT 2024