Re: Pro*C and fork()

From: Michael Krolewski <vandra_at_u.washington.edu>
Date: Wed, 26 Aug 1998 00:01:17 -0700
Message-ID: <35E3B2BD.2C7A41E2_at_u.washington.edu>


I have developed programs running multiple connection simultaneous in more than one thread with no problem. The manual has a very good discription of how to do this. The significant is is determining which connection is being referenced. In OCI, the connection for a particular cursor is quite obvious as you need the connection (Lda_Def) to generate

a cursor (Cda_Def). The major issue is the proper login. Use the one that supports multiple connections.

I cannot recall how you determine the connection assignment under proC, but I presume that this is possible.

Mike Krolewski

Peter Koch wrote:

> Dear readers:
>
> I'm writing a C-program that connects to a database, then
> forks a couple of childs which are supposed to open a seperate
> connection.
>
> main()
> {
> ...
> EXEC SQL CONNECT ... /* Open connection 1 */
>
> Here I want to use connection 1 - no problem
>
> if(fork()){
> /* This is the parent process */
>
> Here I want to use connection 1 - no problem
>
> } else {
> /* This is the child process */
>
> Can I use connection 1 here without interfering with
> the parent - process
>
> EXEC SQL CONNECT ... /* Open connection 2 */
>
> Here I want to use connection 2
> }
>
> Now the problem is, that opening a second connection in the
> child - process seems to nterfere with connection of the
> parent - process.
>
> I'm not familiar with the internals of SqlNet, but my guess is
> that opening a connection will open a socket on port 1521, fork()
> will duplicate the corresponding files-descriptor, but Oracle
> seems to get confused if two processes send data on this socket
> at the same time.
>
> Is this correct?
>
> How do I open a seperate connection in the child process WITHOUT
> closing the original on in the parent-process?
>
> Thanks!
>
> Peter
>
> --
> Peter Koch <Koch_at_Math.Uni-Duisburg.DE> phone: 49 203 379-2698
> Department of Mathematics fax: 49 203 379-3139
> University of Duisburg, Lotharstrasse 65, 47048 Duisburg - Germany
Received on Wed Aug 26 1998 - 09:01:17 CEST

Original text of this message