Re: Informix 7.2 and Threads: Error -439
Posted in 2000
Supriya Madhuram wrote: > > Hello everyone > > I want to know if I can have multi-threaded clients accessing > an Informix 7.2 database. > I have two threads in my application and when both of them > access the db using ESQL statements (preparing and fetching cursors > etc), > I get the a -439 error code. > > finderr -439 > -439 Database server is currently processing an SQL task. > > You attempted to call an SQL routine or attempted to execute an SQL > statement within a signal handling function/routine or a callback > function/procedure. Use only the sqldone() and sqlbreak() library > functions inside your INFORMIX-ESQL/C callback function. Use only the > ECO-SQD and ECO-SQB library routines inside your ESQL/COBOL callback > procedure. In addition, if you want to unregister your callback > function in INFORMIX-ESQL/C, you can invoke the sqlbreakcallback() > callback registration function within your callback procedure. If you > want to unregister your callback procedure in ESQL/COBOL, you can > invoke the ECO-SQBCB callback registration routine within your callback > procedure. > > I am using only one database connection for both threads. Should I Well, that's the problem. Only one thread at a time can use a single connection. You either have to use named connections to get a separate connection for each thread, start a dedicated third thread to service database requests for the other two, or use a semaphore, mutex, and/or a condition to condition to control access to a single thread. In the latter case each thread would take control by locking the semaphore (for example), acquiring the dormant connection with SET CONNECTION..., use the connection to get data, then mark the connection dormant with SET CONNECTION ... DORMANT, and finally releasing the semaphore. When a thread needs the shared connection it would block on the semaphore until the other thread(s) release it. Art S. Kagel > open separate connections and execute the ESQL commands? Will that > solve my problem or should I synchronize the db access so that only > one thread accesses it at any time? Both threads only read the db, > and do not modify or delete anything. > > I am running Informix 7.2 on Solaris 2.51 > > Hope someone can help. > > Supriya Madhuram