Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: ESQL/C and OCI examples using two-phase commit
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
![]() |
![]() |