sqlite3_step can be called several times if your statement returns some rows (like select statement). In this case each call of sqlite3_step except last one will return SQLITE_ROW. Last call will return SQLITE_DONE. And in case of any error sqlite3_step will return SQLITE_ERROR or some extended error code (depending on whether you use default SQLite configuration or you also called sqlite3_extended_result_codes, http://www.sqlite.org/c3ref/extended_result_codes.html). insert/update/delete statements do not return any rows, so sqlite3_step won't ever return SQLITE_ROW for them. It will always be SQLITE_DONE if statement has been executed successfully or SQLITE_ERROR (or extended error code) if statement failed.
One more note: reply to the whole list please, not to me only. Pavel On Tue, Feb 22, 2011 at 8:34 AM, Ali Habib <[email protected]> wrote: > Hi, > sorry for the wrong sending , my problem is that No update happened , I > also I read about sql_step , but I couldn't understand how to apply it , > they said you should run it several times > Best regards > > On Tue, Feb 22, 2011 at 3:24 PM, Pavel Ivanov <[email protected]> wrote: >> >> There are several problems: >> 1) You wrote to the wrong list. sqlite-dev is for those who develop >> SQLite, sqlite-users is for those who develop using SQLite. >> 2) You didn't say what problem you have with that piece of code. >> 3) You didn't call sqlite3_step() after sqlite3_bind_text() to >> actually execute your update statement. >> >> >> Pavel >> >> On Tue, Feb 22, 2011 at 6:43 AM, Ali Habib <[email protected]> >> wrote: >> > Hi all, >> > I want to update database that exists in the user iphone , I use the >> > information in uitextview (animalDesciption ) to update using the >> > following >> > >> > -(IBAction)UpadateData:(id)sender{ >> > >> > sqlite3 *database; >> > >> > // Setup some globals >> > >> > NSString *databaseName = @"test.sql"; >> > >> > // Get the path to the documents directory and append the databaseName >> > >> > NSArray *documentPaths = >> > NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, >> > NSUserDomainMask, >> > YES); >> > >> > NSString *documentsDir = [documentPaths objectAtIndex:0]; >> > >> > NSString * databasePath = [documentsDir >> > stringByAppendingPathComponent:databaseName]; >> > >> > [databasePath retain]; >> > >> > sqlite3_stmt *compiledStatement; >> > >> > if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { >> > >> > const char *sqlStatement = "Update animals set description = ? WHERE >> > name= >> > ?"; >> > >> > //sqlite3_prepare_v2(database, sqlStatement, 1,&compiledStatement, NULL) >> > ; >> > >> > if(sqlite3_prepare_v2(database, sqlStatement , -1, &compiledStatement, >> > NULL)== SQLITE_OK) { >> > >> > sqlite3_bind_text(compiledStatement, 1, [ self.animalDesciption.text >> > UTF8String] , -1, SQLITE_TRANSIENT); >> > >> > sqlite3_bind_text(compiledStatement, 2, [ AnimalName UTF8String], -1, >> > SQLITE_TRANSIENT); >> > >> > sqlite3_reset(compiledStatement); >> > >> > } >> > >> > sqlite3_finalize(compiledStatement); >> > >> > sqlite3_close(database); >> > >> > } >> > >> > >> > } >> > >> > any suggestion, how to fix that please >> > >> > Best regards >> > >> > _______________________________________________ >> > sqlite-dev mailing list >> > [email protected] >> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-dev >> > >> > > > _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

