Maxim Grinev <ma...@...> writes: > > Hi Jocelyn, > > we do not support nested updates in Sedna because: > 1) it is not trivial to implement them as, for example, the nested update > might delete the sequence over which the outer expression is iterating. > 2) Semantic is unclear in many cases. For example, in your expression it is > not clear what should be the result if the document exists - update cannot > return any reasonable result because it is for side-effect. > > We think that it is not that bad because in all cases you can rewrite your > query with nested update into a list of update, query and host language > statements. For example: > 1) run the query "collection('mydocs')/d...@id = '1000']...@timestamp = > '2006-06-12T14:15:30']" from your host language program (i.e. Java) and > analyze the result to find out whether the document exists > 2) if the document exists, run the update statement and then the following > query: <response><ok/></response> > 3) if the document does not exists, run the following query: > <collision>true</collision> > (: also perhaps returning the modified $doc :) > > In many practical cases you can rewrite a query with nested update into a > list of updates and a query without using host language statements if you > slightly modify the logic of the query. We have a number of quite complex > applications where we have avoided using any host language and nested > updates. > > If you have problems to rewrite some query, let us know and we will help you > or tell you that it is impossible without using a host language. > > Maxim > > > -----Original Message----- > > From: sedna-discussion-boun...@... [mailto:sedna- > > discussion-boun...@...] On Behalf Of Raymond, Jocelyn > > Sent: Tuesday, June 13, 2006 7:53 PM > > To: sedna-discuss...@... > > Subject: [Sedna-discussion] Conditional replace (update) > > > > Hi Sedna Team, > > I would like to know if it is possible to do conditional replace in Sedna. > > I was thinking along the line of the following: > > > > let $doc := collection('mydocs')/d...@id = '1000']...@timestamp = '2006-06- > > 12T14:15:30'] > > return > > <response> > > {if($doc) then (: if the $doc exist, it means that no one else > > changed it :) > > UPDATE replace $doc with <new doc with new timestamp./> > > else <collision>true</collision> (: also perhaps returning the > > modified $doc :) > > } > > </response> > > > > What I am trying to accomplish is to avoid replacing $doc that have been > > modified by another party (thus the timestamp). Thus I would like to > > check if the doc did changed since the user was working on it and > > therefore take proper action. If the timestamp is the same it means that > > no one else changed the $doc since the last read otherwise it was > > "saved/changed" by another user. This is a primitive "lock" mechanism but > > essential nonetheless. I have tried several "version" of the above > > without success yet. > > If this is not possible in Sedna, do you have any other alternative or > > perhaps suggestion? (NOTE: my users are on our intranet over https thus > > we cannot know when they are modifying $doc). > > > > Thank you, > > Jocelyn Raymond > > > > PS: I know you must be close to deliver your first stable version of Sedna > > and must be very busy. Thus don't worry if you do not return to me right > > away. I can't wait to see your first stable version especially indexing > > on xs:date O. Your Team is doing a very good job! > > > > > > _______________________________________________ > > Sedna-discussion mailing list > > sedna-discuss...@... > > https://lists.sourceforge.net/lists/listinfo/sedna-discussion > >
Hey Guys, I'm not sure if I understood this correct. You wrote that nested updates in Sedna are not supported. So it's not possible to execute a delete statement with a condition? I will provide a little example: This is my xml document: <books> <book type="hardcover"> <title>A Burnt-Out Case</title> <author>Graham Greene</author> <isbn>0370014995</isbn> <price>13.00</price> </book> <book type="softcover"> <title>American Psycho</title> <author>Bret Easton Ellis</author> <isbn>0679735771</isbn> <price>14.00</price> </book> </books> And now I want to delete the book with the title "American Psycho". I tried a few different statements but non of them worked properly. My statements looked like this one: for $b in doc('books')//books/book where $b/title = 'American Psycho' return ( update delete $b) Thank's! BR, Flo ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Sedna-discussion mailing list Sedna-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sedna-discussion