After several fruitless hours of google searching, I submitted the above question. I then got lucky and found the answer...
http://forums.realsoftware.com/viewtopic.php?f=3&t=3974&hilit=+no+such+column+ Basically, just insert the boolean value in single quotes: i.e. 'true'. Jiim On Sep 29, 3:55 pm, gymshoe <[EMAIL PROTECTED]> wrote: > I have successfully created a test database and do not have trouble > inserting records containing text or integers. However, when I try to > insert a boolean value I get an error "no such column:true". (For > speed of execution, I would prefer to be able to just store booleans > in the database "directly", as opposed to using code to convert > boolean values to 0's and 1's). > > CODE: > > String Id_ = "007"; > Integer age_ = 39; > Boolean spy_ = true; > > db.execSQL("CREATE TABLE IF NOT EXISTS " > + TABLE_NAME > + " (Id TEXT, Age INTEGER," > + " Spy BLOB);"); > > db.execSQL("INSERT INTO "+ TABLE_NAME +" (Id, Age, Spy)" > + " VALUES ("+ Id_ + ","+ age_ +","+ spy_+");"); > > LOGCAT: > 09-29 21:26:11.493: VERBOSE/SQLHelper-onCreate(26139): Table was > created in SQLHelper.onCreate... > 09-29 21:26:11.493: ERROR/Database(26139): Failure 1 (no such column: > true) on 0x7a7c8 when preparing 'INSERT INTO table1 (Id, Age, Spy) > VALUES (007,39,true);'. > > 09-29 21:26:11.503: ERROR/Database(26139): Error executing INSERT INTO > table1 (Id, Age, Spy) VALUES (007,39,true); > > 09-29 21:26:11.513: DEBUG/AndroidRuntime(26139): Shutting down VM > > If I run the same code without the boolean (i.e. only include Id > (string) and age (integer) it works fine. I have tried using TEXT and > INTEGER for the data-format for Spy ("Id TEXT, Age INTEGER, Spy > TEXT"), without effect (not unexpected given manifest typing of > sqlite3). Finally, I get the same error ("no such column:..") if > instead of saving a boolean to the database, I try to save a Drawable > (using "photo BLOB" syntax). > > Upon google search, the only thing I could find which was similar was > a problem with Ruby on Rails (RoR) giving a similar SQLite3 error: > --- > "Does sqlite3 handle booleans differently than MySQL? It seems to > choke when I query based on a boolean. For example: In my controller, > I have this: > > @gameweek = Gameweek.find(:first, :conditions => [ "current = true > and > league_id = ?", @league.id ]) > > In my production log, I get this error: > > ActiveRecord::StatementInvalid (SQLite3::SQLException: no such > column: > true: SELECT * FROM gameweeks WHERE (current = true and league_id = > 1) > LIMIT 1): " > --- > Apparently, this RoR problem is resolved by using the following > format: > @gameweek = Gameweek.find(:first, :conditions => [ "current = ? and > league_id = ?",true, @league.id ]) > > So I tried this kind of format for android: > {db.execSQL("INSERT INTO "+ TABLE_NAME + " (Id, Age, Spy)" + " VALUES > ("+ Id_ + "," + age_ +",[?,"+ spy_+"]);"); > But this didn't work - maybe it's not quite the right syntax, maybe > because it isn't part of a "WHERE" clause? I don't know. > > {Oh, I am still using 0.9SDK, but didn't think it likely related to > that...} > Any ideas on how to handle booleans with SQLite (or where else to > look) would be appreciated. > > thanks, > Jim --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

