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

Home -> Community -> Usenet -> c.d.o.misc -> locking & commit via OCI

locking & commit via OCI

From: Massis Isagholian <massis_at_socal.rr.com>
Date: Thu, 20 Sep 2001 19:37:37 GMT
Message-ID: <5Arq7.27736$bG6.7089430@typhoon.we.rr.com>

Below is a pseudo sequence of events that I need to perform on Oracle via the OCI interface. I've written an application that does this with MS SQL Server using dynamic cursors through ODBC. It seems all the facilities are available to perform this in Oracle, however, I haven't been able to make this work through the combination of PL/SQL and the OCI interface.

I'd really appreciate your suggestions/solutions.

 Thanks,
   Massis

I need an OCI sample program written in C that demonstrates the following:

TIME PROCESS 1 (P1)                     PROCESS 2 (P2)
---- ---------------------------------  ----------------------------------

1    SELECT AMT FROM T1
        WHERE KEY=2 FOR UPDATE;

2    SELECT AMT FROM T1
        WHERE KEY=1 FOR UPDATE;

(Assume AMT=20)
(RECORD IS NOW LOCKED BY P1)
3 SELECT AMT FROM T1 WHERE KEY=1; (AMT = 20) (RECORD LOCKED BY P1) 4 UPDATE T1 SET AMT=30 WHERE KEY = 1;
(NOTE: record must remain
locked, and new value must be visable at read commited isolation level)
(I've used dynamic cursors with
"UPDATE ... CURRENT OF ..." to acheive this in SQL Server) 5 SELECT AMT FROM T1 WHERE KEY=1; (AMT=30, Note: picked up new value set by P1) (RECORD STILL LOCKED BY P1) 6 SELECT * FROM T1 WHERE KEY=2 FOR UPDATE (NOTE: This will block until P1 releases the record) 7 Release T1 WHERE KEY = 1
(NOTE: T1 KEY = 2,
record must remain locked) 8 Release T1 WHERE KEY = 2
(NOTE: Process 2 will now
unblock from step 6)
Received on Thu Sep 20 2001 - 14:37:37 CDT

Original text of this message

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