Re: thread safe sqlca-value

From: Roland <e9426992_at_stud4.tuwien.ac.at>
Date: 1999/10/31
Message-ID: <381B6D60.D2A07534_at_stud4.tuwien.ac.at>#1/1


Hi Tom!
Thanks a lot!
Ur suggestion seems to be pretty cool!
I will try this!!!
Thanks!!

Thomas Kyte wrote:
>
> A copy of this was sent to Roland <e9426992_at_stud4.tuwien.ac.at>
> (if that email address didn't require changing)
> On Sat, 30 Oct 1999 08:56:20 +0200, you wrote:
>
> >Hi!
> >
> >I am developing a multi-threaded server (in c) using oracle pro*c to
> >access an oracle-db on linux, using oracle 8.0.5.
> >
> >If i have lots of threads, do I have to mutex the sqlca accesses or not?
> >I have 1 session context, but more than 1 accesses to the database, and
> >the threads
> >are pretty complex (they call lots of functions), so in the end: i do
> >not know WHAT action a thread at a given time does perform.
> >
> >As far as I could figure out, the sqlca datastructure is the only
> >dangerous part, is this correct?
> >
> >Thanks for ur help!
> >Roland.
>
> Just make sure each subroutine puts the sqlca on the stack -- not in the data --
> so you don't have to mutex around every call. eg:
>
> #include <stdio.h>
> #include <string.h>
>
> #define SQLCA_INIT
> EXEC SQL INCLUDE sqlca; // defines a GLOBAL one, but we won't use that one
>
> static int process( char * tname )
> {
> struct sqlca sqlca; // gives this subroutine its own sqlca
> // all proc calls pass the &sqlca down to the
> // lower level stuff so this makes it threadsafe
> // since C scoping rules will have us passing the
> // address of our stack variable -- not the single
> // global above. If you have an error routine, you'll
> // have to pass it this structure of course, not just
> // refer to the global sqlca struct as that one will
> // not be used.
>
> EXEC SQL BEGIN DECLARE SECTION;
> varchar c[8][10];
> EXEC SQL END DECLARE SECTION;
>
> .......
>
> --
> See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
> Current article is "Part I of V, Autonomous Transactions" updated June 21'st
>
> Thomas Kyte tkyte_at_us.oracle.com
> Oracle Service Industries Reston, VA USA
>
> Opinions are mine and do not necessarily reflect those of Oracle Corporation
 

-- 
"Pascal is Pascal is Pascal is dog meat."
		-- M. Devine and P. Larson, Computer Science 340

join my ArchibalD-mailinglist!
send an empty mail to: archibald-list_at_listbot.com
-----------------------------------------------------
                 Roland Schaffer

            e9426992_at_stud4.tuwien.ac.at
	http://www.bitsmart.com/roland_schaffer
          http://stud4.tuwien.ac.at/~e9426992
######################################################
Received on Sun Oct 31 1999 - 00:00:00 CEST

Original text of this message