Hi Garrett,

Sorry, for the delay. Below you can find my comments ...

The count would be determined by executing the following query (would return
> 10 in the above example):
> data(doc("COUNTER")/COUNTER)
>
> The count would be incrementd by 5 with the following query:
> UPDATE REPLACE $x in doc("COUNTER")/COUNTER/COUNT with
> <COUNT>{$x+5}</COUNT>
>
> Then starting at 11 till 15, Elements would be added in with the following
> query (with x replaced by number)
> UPDATE insert(<ELENMENTx id='x'></ELEMENTx>) into doc("doc")//
>
> Is there a way to ensure that between the read of the COUNT value, and the
> UPDATE of the COUNT value, that no other client reads or writes to the COUNT
> value?
>

To prevent counter read between the first and second statements you just
need to swap them - first you update counter (and ensure exclusive locking
on doc('counter')), then you read the value (since delta is known it's easy
to get initial value):

(:begin transaction:)
UPDATE REPLACE $x in doc("COUNTER")/COUNTER/COUNT with <COUNT>{$x+5}</COUNT>
data(doc("COUNTER")/COUNTER) - 5
(:end transaction:)

Note, don't forget that at least first two statement must be within one
transaction.

BTW, try also to replace text() node instead of the whole <count>, something
like this should work (let me know if it doesn't :) ):

UPDATE REPLACE $x in doc("COUNTER")/COUNTER/COUNT/text() with string($x+5)


Ivan Shcheklein,
Sedna Team
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Sedna-discussion mailing list
Sedna-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to