several updates in one xquery
Hi Sedna Team,
I previously sent a post asking how to make several updates in a single xquery (see below). I would like to
share what I found (there is a way). Please let me know if you have something better or if you have any
comments regarding the efficiency of the xquery below. Note that there are two variations.
Variation One: One document fragment to be inserted into several documents.
UPDATE
insert
<individual id="2003" role="attandant"/>
into
((index-scan("idx_event_id", "1000","EQ")/individuals),
(index-scan("idx_event_id", "1002","EQ")/individuals),
(index-scan("idx_event_id", "1005","EQ")/individuals),
(index-scan("idx_event_id", "1006","EQ")/individuals))
Variation Two: Several document fragments to be inserted into one document.
UPDATE
insert
for $fragment in ((<individual id="2003" role="attendant"/>),
(<individual id="2004" role="guide"/>),
(<individual id="2007" role="attendant"/>))
return $fragment
into
index-scan('idx_event_id','1000','EQ')/individuals
This means that instead of sending several network calls to the sedna database, only one is needed
therefore reducing network traffic. Hope this can help others.
Thank you,
Jocelyn Raymond
________________________________________
From: Raymond, Jocelyn
Sent: Thursday, July 06, 2006 3:12 PM
To: 'sedna-discussion@...'
Subject: several updates in one xquery
Hi Sedna Team,
Is it possible to construct several UPDATE inside one xquery?
I would like, if possible, to avoid network traffic for each update that I need to do. For instance, my Java
program loop through a collection, construct the xquery, send it over the network and process the next one
in the collection. However, would it be possible to loop through the entire collection first, building
one xquery then send it over the network (thus one network call)?
Something like:
((UPDATE insert <individual id="2003" role="attandant"/> into index-scan("idx_event_id",
"1000","EQ")/individuals),(UPDATE insert <individual id="2003" role="attandant"/> into
index-scan("idx_event_id", "1002","EQ")/individuals),(UPDATE insert <individual id="2003"
role="attandant"/> into index-scan("idx_event_id", "1005","EQ")/individuals),(UPDATE insert
<individual id="2003" role="attandant"/> into index-scan("idx_event_id", "1006","EQ")/individuals))
Note that the above is one string. To make it clear it can be broken down to:
((UPDATE insert <individual id="2003" role="attandant"/> into index-scan("idx_event_id", "1000","EQ")/individuals),
(UPDATE insert <individual id="2003" role="attandant"/> into index-scan("idx_event_id", "1002","EQ")/individuals),
(UPDATE insert <individual id="2003" role="attandant"/> into index-scan("idx_event_id", "1005","EQ")/individuals),
(UPDATE insert <individual id="2003" role="attandant"/> into index-scan("idx_event_id", "1006","EQ")/individuals))
This is a sequence of Update but it does not work. If such a xquery is possible or any other xquery tricks,
let me know, it would be very much appreciated.
Jocelyn Raymond