Ah. That will answer what I just posted now, I suspect... OK will have a 
shot at doing it that way and see how it goes. Still learning. Thanks :)

Charles Foster wrote:
> Hi Dean, say the username is "steve" the result of your current XQuery
> expression is:
>
> "for $x in //aRecord
> where $x/id = steve
> return $x"
>
> "steve" must be defined as "steve" or xs:string("steve"), etc otherwise it
> an XQuery exception will occur.
>
> So either inline this into your query as appropriate.
>
> Another thing to point out Dean,  once you solve this error you will only
> run into another.
>
> "ResourceIterator results = resultSet.getIterator();"
>
> This will return you a result set of the query,
> e.g. just the root nodes, this will not return you the resource ids, so
> the XML:DB API
> will not know which records you actually want to delete based on this query.
>
> If you insist on using XML:DB without Sedna UPDATE language, then try the
> following:
>
> // ---------
> String username = "steve";
>
> XQueryService xqs = (XQueryService)bookings.getService("XQueryService",
> "1.0");
> xqs.declareVariable("username", username);
> ResourceSet rs = xqs.query("for $x in //booking where $x/id = $username
> return document-uri(root($x))");
>
> ResourceIterator iter = rs.getIterator();
> while(iter.hasMoreResources())
> {
>   String documentId = iter.nextResource().toString();
>       Resource res = bookings.getResource(documentId);
>   bookings.removeResource(res);
> }
>
> bookings.close();
> // ---------
>
> I actually suggest that you use Sedna UPDATE language to complete this task,
> the method described above is no way near as efficient, because it involves:
>
> 1. An XQuery
> 2. Processing Results
> 3. Retrieving Documents
> 4. Deleting Documents
>
> Where a Sedna UPDATE statement would be just:
>
> 1. Delete documents based on requirements.
>
> To execute a Sedna UPDATE statement, use either:
>
> SednaUpdateService.update(String sednaUpdateStatement);
> or
> XQueryService.execute(CompiledExpression expression);
> or
> XQueryService.query(String sednaUpdateStatement);
>
> Regards,
>
> Charles


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sedna-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to