Busted Mug

A blog that documents solutions to the most frustrating problems that occur during development in technologies such as Java, XML, AJAX, SQL, CSS and others that make me want to throw my coffee mug against the cube wall.

Tuesday, March 25, 2008

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:

while (rs.isValidRow()) { console.log(rs.fieldName(0) + " == " + rs.field(0)); rs.next(); } rs.close();

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...

21 Comments:

At 5:29 PM, Blogger Brad Neuberg said...

Hi Brando, good idea; I just forwarded this on to the Gears engineering list.

Best,
Brad Neuberg
Google Developer Program

 
At 6:52 AM, Blogger Brando said...

Thanks, Brad!

 
At 9:08 PM, Blogger Kyle Zarazan said...

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

 
At 6:36 AM, Anonymous 友達募集中 said...

初書き込みで申し訳ないんですが、都合のいい男性探しています。不況の中でも会社が高成長してて、忙しい毎日です。お陰でプライベートが充実していなくって、溜まる一方です。財産的にも多少余裕が今のところあるのでお礼もできます。何より、この書き込みが読まれているのかちょっと怪しいですけど…。アドレス置いとくので、消されないうちにメールくれたら嬉しいです。inspiration.you@docomo.ne.jp

 
At 7:52 AM, Anonymous 出張ホスト said...

結婚してから女としての喜びを失った玉の輿女性達、エリート旦那のそつのない動きには満足できるはずもなく、時間を持て余すお昼時に旦那のお金を使い、出張ホストサービスを楽しむそうでございます。今回も10万円での愛を承っております。癒しの一時をご一緒して謝礼を貰ってくださいませ

 
At 7:27 AM, Anonymous gree said...

だれもが知っている日本で一番有名な出会い系スタービーチがついに復活、greeより面白い新生スタビをやってみませんか?理想のパートナー探し、合コンパーティーに興味がある方はぜひ無料登録してみてください

 
At 6:53 AM, Anonymous 玉の輿度チェッカー said...

当サイトは、みんなが玉の輿に乗れるかどうか診断できる性格診断のサイトです。ホントのあなたをズバリ分析しちゃいます!玉の輿度チェッカーの診断結果には、期待以上の意外な結果があるかも

 
At 7:01 AM, Anonymous デリバリーホスト said...

男性との甘い一時が奥様達には必要になっております。刺激のない私生活はとても辛く、ココロもカラダもストレスが堪る一方、そんな中にデリバリーホストに癒しを求めている奥様、セレブ女性は大変増えてきており、男性の方が不足状態です。女性達の癒しとなる仕事をあなた様も一度体験してみてはいかがでしょうか

 
At 6:09 AM, Anonymous リア友 said...

メル友らんどでは誰でも気軽にメル友が作れちゃう、参加無料でいつでも利用可能なコミュニティサイト♪ご近所の気の合うリア友や、真面目に彼氏彼女探しなど、楽しみ方は無限大!自分にぴったりの相手を見つけちゃおう

 
At 7:48 AM, Anonymous 出会い said...

大好評の逆ナンイベントが毎週開催決定!素敵な出会いのきっかけ探し・アイナビにきませんか?積極的な出会いを求める人達なら無料参加OK!あなたもほんの少しの勇気で素敵な彼氏・彼女をGETしちゃおう

 
At 5:51 AM, Anonymous お家遊びに来てくれる人いないかなぁ? said...

一人暮らし寂しいよ~(泣)誰かお家遊びにきてくれないかなぁ?休みの日とかも全然予定ありません。料理作るの得意だから来てくれたら食べてほしいな♪見た目は悪くないと思うから安心してください!(笑)細かい事は気にしないけど18歳未満の人は微妙かな、気軽に仲良くしてください milky-yukinko@docomo.ne.jp

 
At 6:55 AM, Anonymous 神待ち said...

冬に1人でネカフェとか寂しすぎやし、でも自分から積極的に声を掛けれる娘ばかりと違い、内気な娘は神待ちと言われるように自分の事を助けてくれるのを待ってるんです。貴方の優しさを待ってる娘は意外な程多いよ

 
At 6:53 AM, Anonymous 名言チェッカー said...

簡単な設問に答えるだけで貴方にふさわしい名言がわかる、名言チェッカー!あなたの本当の性格を見抜いちゃいます。世界の偉人達が残した名言にはどことなく重みがあるものです

 
At 7:04 AM, Anonymous 1人H said...

1人Hを男性に見てもらうことで興奮する女性が多数いることをご存じですか?当サイトにはそんな女性たちが多数登録されています。男性は彼女たちの1人Hを見てあげるだけで謝礼を貰えるシステムとなっております

 
At 6:15 AM, Anonymous モバゲー said...

最高の遊び場、スタービーチ!日本最大の友達探しサイトがついに復活、モバゲーより面白い新生スタビをやってみませんか?理想のパートナー探しの手助け、合コンパーティー等も随時開催しています。楽しかった頃のスタビを体験しよう

 
At 7:08 AM, Anonymous 円倶楽部 said...

当逆円倶楽部ではリッチなセレブと割り切りでお付き合いしてくださる男性を募集しています。女性の性欲を満たし、高額報酬をもらって楽しく暮らしてみませんか?興味がある方はアルバイト感覚での1日登録もできる、安心の無料入会を今すぐどうぞ。

 
At 7:33 AM, Anonymous 旦那以外とエッチしたい said...

人妻だけどセフレ募集しちゃいます!こんな女嫌かなぁ?新しい刺激欲しいし旦那以外の男性としてみたいな。エッチのテクはそれなりに自信あるよ、フェラとか上手いってよく褒められます。年上は何歳まででもOKだけど年下は18歳までが限界かな、楽しみたい人いたら気軽によろしくね♪ enjoy-smile.of.happiness@docomo.ne.jp

 
At 7:02 AM, Anonymous 神待ち said...

家出中の少女たちの書込が神待ち掲示板に増えています。ご飯を食べさせてあげたり、家に招いて泊まらせてあげるだけで、彼女たちはあなたに精一杯のお礼をしてくれるはずです

 
At 7:21 AM, Anonymous 天然娘 said...

さびしがりやの素人女性や天然娘にメールやチャットで会話してあげるだけで儲かる新感覚のアルバイト「素人ホスト」!未経験者の方でも簡単、手軽に出来るお仕事です。詳細は当サイトでご確認ください

 
At 7:14 AM, Anonymous 右脳左脳チェッカー said...

ランク王国でもご紹介された右脳左脳チェッカー、天才肌を見分ける楽しい盛り上がりツールとして今、支持をうけております。みんなでやれば盛り上がる事は間違いなし診断結果でも全国ランキングなどにランクインされて面白さ倍増!話のネタに一度はどうぞ

 
At 5:23 AM, Blogger Unknown said...

Learn essential library routines at http://www.unn.edu.ng/department/library-and-information-science

 

Post a Comment

<< Home