Generic-user-small Gopikrishnan... 3 posts

Hi,

Could you please help me how to retrieve the database values(Sqlite3), I have Completed insert the Value to database but how to retrieve the data’s ?

Thanks for your Help,
Gopikrishnan.P

 
N614592285_2406_small Chris Adamson 153 posts

Pages 144-146 of beta 6 of the book cover how to do a query and retrieve values. Basically, you prepare an SQL “select” statement, step through result rows with sqlite3_step, and pick out elements of each result with sqlite3_column_XXX-style functions.

 
Generic-user-small Nickolay Nic... 1 post

Hello,

regarding this topic, I’d like to add a note about what I have stumbled on.

The data I am storing is a UTF8 coded (some cyrillic text and few IPA notation signs), so I had to change the presented example (bottom page 145):
NSString *itemValue = [[NSString alloc] initWithCString: (char*) sqlite3_column_text (dbps, 1)];

to

NSString *itemValue = [[NSString alloc] initWithUTF8String:(char*) sqlite3_column_text (dbps, 1)];

Actually it looks like the SQLite stores it’s text data internally in UTF8, so probably this is a better approach for getting the data into the NSString.
Just thought that it can be useful to someone.

Thanks,
Nickolay Nickolaev

 
Photo_13_small Bill Dudney 653 posts

Hi Nickolay,

Thanks for the suggestion!

I will update the code for the next beta.

4 posts, 4 voices