Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: ESQL/C and OCI examples using two-phase commit

Re: ESQL/C and OCI examples using two-phase commit

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/08/06
Message-ID: <33eac296.17977690@newshost>#1/1

You don't need to do anything special like connecting to 2 databases in PRO*C or OCI. Its as simple as it looks. Here is the pro*c for example that would do it:

strcpy( userid.arr, "scott/tiger" );
userid.len = strlen( userid.arr );

exec sql connect :userid;

exec sql insert into test1 values (3, 'zzzz'); exec sql insert into test2_at_ora.mandela.telco.stratus.com values (3, 'cccc'); exec sql commit;

thats it. OCI would be very similar in nature but the API calls are very different. You just connect to one database and access the other via a dblink. Commit and all is commited for you. There is no need for extra code to 2pc.

On Wed, 06 Aug 1997 12:03:55 -0400, Jerry Abramson <jerry_abramson_at_stratus.com> wrote:

>I am currently experimenting with Oracle7's two-phase commit. I
>have done it in SQL*plus like this (All the distributed database
>links have been set up between the two databases):
>
>jazz$ sqlplus scott/tiger
>SQL*Plus: Release 3.3.2.0.0 - Production on Wed Aug 6 11:59:08 1997
>
>Copyright (c) Oracle Corporation 1979, 1994. All rights reserved.
>
>
>Connected to:
>Oracle7 Server Release 7.3.2.3.0 - Production Release
>With the distributed, replication, parallel query and Spatial Data
>options
>PL/SQL Release 2.3.2.3.0 - Production
>
>SQL> connect scott/tiger_at_mandela;
>SQL> set autocommit off;
>SQL> insert into test1 values (3, 'zzzz');
>
>1 row created.
>
>SQL> insert into test2_at_ora.mandela.telco.stratus.com values (3, 'cccc');
>
>1 row created.
>
>SQL> commit;
>
>Commit complete.
>
>Now I would like to do the same thing from within an ESQL/C program and
>an
>OCI program. Do I need to use the:
> CONNECT :user IDENTIFIED BY :pw AT db_name USING :net_string
>syntax? How else can I get connected to both databases? Once I am
>connected I would think it is straight-forward.
>
>I also need to do this from OCI, an example would be greatly
>appreciated!

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD

http://govt.us.oracle.com/ -- downloadable utilities



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Aug 06 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US