Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 648691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:51:38+00:00 2026-05-13T21:51:38+00:00

the following code (from a database object created for each new view): -(void)update:(NSString *)queryText{

  • 0

the following code (from a database object created for each new view):


-(void)update:(NSString *)queryText{
    NSLog(queryText);
    char *errorMsg;

    if (sqlite3_prepare_v2(database, [queryText UTF8String], -1, &statement, nil) == SQLITE_OK) {
    } else {
        NSLog(@"HMM, COULDNT RUN QUERY: %s\n", sqlite3_errmsg(database));  
    }
    if (sqlite3_step(statement) != SQLITE_DONE){
        NSAssert1(0, @"Error updating table: %s", errorMsg); 
    }
    sqlite3_finalize(statement);
    NSLog(@"Update saved");
}
-(void)insert_answer:(int)obj_id question_type:(NSString *)question_type score:(int)score{
    char *errorMsg;
    char *update = "INSERT INTO Answers (obj_id, question_type, score, date) VALUES (?, ?, ?, DATE())";
    //sqlite3_stmt *stmt;
    if (sqlite3_prepare_v2(database, update, -1, &statement, nil) == SQLITE_OK) { 
        sqlite3_bind_int(statement, 1, obj_id);
        sqlite3_bind_text(statement, 2, [question_type UTF8String], -1, NULL);
        sqlite3_bind_int(statement, 3, score);
    } 
    if (sqlite3_step(statement) != SQLITE_DONE){
        NSAssert1(0, @"Error inserting: %s", errorMsg); 
    }
    sqlite3_finalize(statement);
    NSLog(@"Answer saved");
}

is called by my app from this code:


    [db insert_answer:[[dict_question objectForKey:@"JISDec"] intValue] question_type:@"kanji_meaning" score:arc4random() % 100];
    //
    //update EF, Next_question, n here
    //
    [db update:[NSString stringWithFormat:@"UPDATE Kanji SET EF = %d WHERE Kanji = '%@'", [[dict_question objectForKey:@"EF"] intValue] + 2, [dict_question objectForKey:@"question"]]];
    [db update:[NSString stringWithFormat:@"UPDATE Kanji SET Next_Question = %d WHERE Kanji = '%@'", 1, [dict_question objectForKey:@"question"]]];
    [db update:[NSString stringWithFormat:@"UPDATE Kanji SET n = %d WHERE Kanji = '%@'", [[dict_question objectForKey:@"n"] intValue] + 1, [dict_question objectForKey:@"question"]]];

and runs fine the first time a question is answered in my app, but the next time (after a new view is loaded) it returns an assert error and crashes.

Does anyone know why??? I have almost exactly the same code in another app and it has no problems.

Many thanks.

EDIT: Added stack:


2010-03-08 03:01:12.107 Kanji[33864:207] *** Assertion failure in -[databaseConnection update:], /Volumes/Xcode/Kanji/Classes/../databaseConnection.m:58
2010-03-08 03:01:12.108 Kanji[33864:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error updating table: (null)'
2010-03-08 03:01:12.109 Kanji Training with Watanabe Sensei[33864:207] Stack: (
    30135387,
    2561586441,
    30219323,
    814852,
    37730,
    18074,
    2757637,
    3165006,
    3173743,
    3168955,
    2862559,
    2770888,
    2797665,
    37424473,
    29920128,
    29916232,
    37418517,
    37418714,
    2801583
)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:51:39+00:00Added an answer on May 13, 2026 at 9:51 pm

    It would help if you would show the ‘assert error’ and maybe a stacktrace to see what call actually fails.

    Also, note that even though you are checking for errors, you are not doing it correctly. Even if an error happens, you continue to exeute sqlite functions. That is a recipe for disaster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to query a database from my jsp, but I'd
I have got the following code from here to read an Excel file using
When I try to run the following code (from the REPL) in Clojure: (dotimes
Given the following code snippet from inside a method; NSBezierPath * tempPath = [NSBezierPath
So I have the following code: return from a in DBContext.Acts join artist in
I want to compile the following line of code from http://code.google.com/p/enhsim : enh::eout <<
The following code should find the appropriate project tag and remove it from the
I'm using the following code within the JCProperty class to retrieve data from a
I ran across the following code in Ely Greenfield's SuperImage from his Book component
currently I have the following code: String select = qry.substring(select .length(),qry2.indexOf( from )); String[]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.