I think Vincent Wolowski wrote:
> If you know that the query returns only one result, is there a way not to use an
>Iterator and get the value directly?
>
No, but I can simplify your code in a couple of ways.
>
> String query = "(defquery elementSearch (Tag (ElementID "+elementID+") ParentID
>"+parentID+")))";
> r.executeCommand(query);
> r.store("RESULT2", r.runQuery("elementSearch", new ValueVector()));
> Iterator e = (Iterator) r.fetch("RESULT2").externalAddressValue(null);
Don't know why you're storing this result, only to fetch it in the
next line. Why not just replace the two lines above with:
Iterator e = r.runQuery("elementSearch", new ValueVector());
...
> r.executeCommand("(defquery childElementCount (Tag (ParentID "+elementID+")))");
> r.executeCommand("(bind ?n (count-query-results childElementCount))");
> Value v = (r.getGlobalContext()).getVariable("n");
> number = v.intValue(context);
Not sure why you're using the variable "n". What's wrong with just
doing this:
number = r.executeCommand("(count-query-results childElementCount)").intValue(null);
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------