QueryResult.getNext() method of TaminoResult question

Hi every ,
In order to improve my program efficiency,I should clear this question :
If i set the pagesize , It returns one pagesize of result to client,
when it executes QueryResult.getNext().getResult(),it will returns the next pagesize, that is it returns one pagesize at a time?
Thanks,
lisa

getNext/getPrev are designed to allow you to page through a number of results satisfying a particular query. For example instead of dealing with a 1000 large result nodes all at once you may deal with them 10 at a time. It is similar in principle to Next/Previous on browsers.

Hi markk,
you means that at a time, a pagesize result will be sent to client from the tamino server??

And I will ask if the QueryResult.getNext() will work together with getResult(), that is to say after execute the QueryResult.getNext(), then we should execute QueryResult.getResult()?

But to my surprise , not all the Tamino result project will support the getResult() method.
Such as I can use
tamResult = tamClient.query("…");
tamResult.DOM.documentElement.xml"
but I can’t use tamResult.getresult();
Why???

And when I set the pageSize , how can i deal with many result at several times based that I can only use the tamResult.Dom and other DOM method.

BTW: i have read all the document of jsaip,and try a few method to do it ,but failed, can you help me??

thanks,
lisa

getNext/getPrev return NEW TaminoResult objects that you may then use.

The more efficient way of using getNext/getPrev is from within a transactional session. To do this you need to set the global TaminoLib vars:

inoRealCursoring=true;
inoCursorScrollableOn=“yes”;

This will work with Tamino 3 and above.

It is possible that getResult will NOT work if you are using MSXML4 rather than MSXML3. The reason is that MSXML4 is more exacting about using namespaces in XPath lookups - this was a problem in earlier TaminoLib.js implementations - it is now fixed. getResult is checking for an xql:result element in the response document.

The fix applied to later TaminoLib.js is in the TaminoResult constructor. After checking for errors the SelectionNamespaces property is set:

var p = this.DOM.parseError;

if (p.errorCode != “0”)
{
this.errorNo=inoParserErrorNo;
this.errorText =
TaminoClientErrorText(inoParserErrorNo, p.errorCode,p.reason);
return;
}

// needed for MSXML4 and above for namespace XPath searches
this.DOM.setProperty(“SelectionNamespaces”,
“xmlns:ino=‘http://namespaces.softwareag.com/tamino/response2’ xmlns:xql=‘http://metalab.unc.edu/xql/’ xmlns:xq=‘http://namespaces.softwareag.com/tamino/XQuery/result’”);

Hi markk,

Thanks for your explanation.
And also I solved my question last night.

Best Regards,
lisa

Hi markk,
my former method to achieve the next/prev page function is not very efficient,So i use method which you give me,However I find that not only getResult() not can be used in my pc,but also getPrev(). (In my former method, i use the getnext() to chieve previous page function) And why??the cause is the same as the getResult()??



I find the code in function TaminoResult(queryo,req,noBody) of TaminoLib.js : var p = this.DOM.parseError;

if (p.errorCode != “0”)
{
this.errorNo=inoParserErrorNo;
this.errorText =
TaminoClientErrorText(inoParserErrorNo, p.errorCode,p.reason);
return;
}


and also add the code to function TaminoResult(queryo,req,noBody),but getResult(), and getPrev can’t work either.

why??and how can i to do???

thanks
lisa

It is not very easy to answer “why” if one can’t see the code or data.

What code are you using to do next/previous - just try to provide the minimum possible. Also what does the first response document look like? I.e. the first tamResult.DOM.documentElement.xml?

var dbname = “http://localhost/tamino/library/book_BasicInf”;
var inoRealCursoring=true;
var inoCursorScrollableOn=“yes”;
var QueryObj = new TaminoClient(dbname, pageSize);
var QueryVal = ‘/?’;
var QueryBak = QueryObj.query(QueryVal);
//all those are global var,

code as follow:

 if(WhichPage == "next" && QueryBak.getNext())
     {
      QueryResult = QueryBak.getNext();  
     }
else if( WhichPage == "Prev" &&QueryBak.getPrev())
    {
       QueryResult = QueryBak.getPrev(); 
    }
......// the code of displaying the data of result has been omitted.

QueryBak = QueryResult;//save the queryResult.



the program doesn’t execute the code of “else if( WhichPage == “Prev” &&QueryBak.getPrev())
{
QueryResult = QueryBak.getPrev();
}” although the result has been execute 10 times QueryBak.getNext();

MY test code is that this:

 
if(WhichPage == "next" || WhichPage == "Prev")
 {
    alert(QueryBak );
    if( QueryBak.getNext())
      alert(QueryBak.getNext() + "next is :" + QueryBak.getNext().DOM.documentElement.xml);
    if( QueryBak.getPrev()) 
alert(QueryBak.getPrev() + "prev is :" + QueryBak.getPrev().DOM.documentElement.xml);

...
QueryBak = QueryResult;
   
 </pre><BR><BR>when I test, I just to see "[object object] next is:..." ,not to see ""[object object] prev is:..."<BR><BR>then I modify the code like this:<BR><pre class="ip-ubbcode-code-pre">  

if(WhichPage == "next" || WhichPage == "Prev")
  {
    alert(QueryBak );
    if( QueryBak.getNext())
     {
       alert(QueryBak.getNext() + "next is :" + QueryBak.getNext().DOM.documentElement.xml);
       document.all("currentCount").value = parseInt(document.all("currentCount").value)+1;}
       alert("i=" + document.all("currentCount").value);
     if( QueryBak.getPrev())
    alert(QueryBak.getPrev() + "prev is :" + QueryBak.getPrev().DOM.documentElement.xml);
   if(document.all("currentCount").value==3)
     {
    alert(document.all("currentCount").value);   
   alert("prev is :" + QueryBak.getPrev().DOM.documentElement.xml)
    }
 }           



After server times to execute this function ,then after displaying i=3, it displays “QueryBak.getPrev().DOM” is null or not a subject .

modify “alert(“prev is :” + QueryBak.getPrev().DOM.documentElement.xml)
” to “alert(“prev is :” + QueryBak.getPrev().)

after displaying “i=3”, it displays “prev is null”,
//this means it supports the getPrev() method???
but why not hava some data rusult??
modify “alert(“prev is :” + QueryBak.getPrev().DOM.documentElement.xml)
” to "alert(“prev is :” + QueryBak.getResult().)
"
after displaying “i=3”, it displays "prev is ",

// and this means what?support it or not??

[This message was edited by lisa on 13 May 2003 at 15:01.]

getNext/getPrev actually move a page and return the result. Your code looks like it attempts to move forwards/backwards 2 times each page movement. getPrev can ONLY be called after at least 1 successful getNext.

// turn on real cursoring - no vars!
inoRealCursoring=true;
inoCursorScrollableOn="yes";

var QueryObj = new TaminoClient(dbname, pageSize);
var QueryBak = QueryObj.query('/?');
var QueryResult;

if (WhichPage == "Next")
{
    QueryResult = QueryBak.getNext();  
}
else if (WhichPage == "Prev")
{
    QueryResult = QueryBak.getPrev(); 
}

// display result

QueryBak = QueryResult;   //save the query result

You MUST only call getNext/getPrev ONCE per page movement required.

if (useNext)
{
    result = result.getNext();

    if (result)
    {
         // have a next page use it
    }
}
else
{
    result = result.getPrev();
    
    if (result)
    {
        // have a previous page use it
    }
}

inoRealCursoring=true;
inoCursorScrollableOn=“yes”;

var QueryObj = new TaminoClient(dbname, pageSize);
var QueryBak = QueryObj.query(’/?’);
var QueryResult;

if (WhichPage == “Next”)
{
QueryResult = QueryBak.getNext();
alert(“next” +QueryResult.DOM.documentElement.xml);
}
else if (WhichPage == “Prev”)
{
QueryResult = QueryBak.getPrev();
alert(“Prev here” + QueryBak.getPrev());
}

// display result

QueryBak = QueryResult; //save the query result


After three times forwards ,then one time backwards,
it displays :“prev here null”

code as follow ,have the same result:
After three times forwards ,then one time backwards,
it displays :"prev here null"

so,i don’t think it is only calling getNext/getPrev ONCE per page movement required question,
I used many times of queryresult.getnext at one page ,it have no error happened…

if (WhichPage == “Next”)
{
QueryResult = QueryBak.getNext();
alert(“next” +QueryResult.DOM.documentElement.xml);
}
else if (WhichPage == “Prev”)
{
QueryResult = QueryBak.getPrev();
alert(“Prev here” + QueryResult);
}

// display result

QueryBak = QueryResult; //save the query result

I suspect that the previous page may be “bigger” tha the next page. I think there may have been a fault in earlier versions whereby the requested page size returned to the default for previous requests and was not the pagesize as specified by the constructor.

How many next/previous can you do if you specify a pagesize of 1?