Database operation failed. ERROR: library routine called out of sequence DETAILS: not an error
I ran into this guy "Database operation failed. ERROR: library routine called out of sequence DETAILS: not an error" while working on a google gears application. The error comes from SQL Lite (the technology under the sheets of gears' data store). There didn't seem to be much documentation on the web to help but finally from placing lots of alert statements (don't you love javascript?) I narrowed it down to a call to rs.next(). I knew the data set would be empty so I immediately suspected I was doing something wrong with checking for the end of the RS.
My suspicions were confirmed when I found the following code block at http://code.google.com/apis/gears/api_database.html#ResultSet:
It appears I missed something basic. Unlike both Oracle and MySQL, when grabbing a new row in SQL Lite in Gears there isn't any automatic evaluation that the row is valid. You have to explicitly call the isValidRow() method. This leaves out the nice and tidy while(rs.next) loops that we all love so much. The first row comes pre-loaded then you have to next after each use. As the dude would say "That's a bummer, Man." I hope I head off someone else freaking out over this novice problem when working in Gears. Maybe SQL Lite/Gears will eliminate the need for the call some day, until then...


3 Comments:
Hi Brando, good idea; I just forwarded this on to the Gears engineering list.
Best,
Brad Neuberg
Google Developer Program
Thanks, Brad!
I have received the same error working on a Google Gears project. However I have come upon a more disturbing complication. I am using the same kind of loop you talk about, "while(rs.isValidRow()) {", but my initial query sometimes returns no result set. This seems to be due to the fact that Gears insists on loading the first result before it even checks if there is a valid row, and when there are no valid rows it throws this error. On a brighter side it does not seems to affect the way the program runs but you are absolutely correct they should change this not just because our while loops will look nicer. Thanks for blogging about it, I have started my own blog because of blogs like this one that have helped me out. Here is a link if you would like to take a look: www.midnightmethods.blogspot.com
Post a Comment
<< Home