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 6363669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:03:59+00:00 2026-05-25T00:03:59+00:00

I am not able to delete data from SQlite database. I have created a

  • 0

I am not able to delete data from SQlite database. I have created a database of Places.
and I am able to display it in UItableView. But when I try to delete something from it code crashes.

The error I am getting is

Assertion failure in -[Place deleteFromDatabase], /Desktop/Current_cortes/Classes/Place.m:148

Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Error: failed to prepare statement with message ‘library routine called out of sequence’.

Here is the the part where program crashed.

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (editingStyle == UITableViewCellEditingStyleDelete) 
    {
        
        NSLog(@"Rows can be edited");
        // Delete the row from the data source.
        Place *PlaceObj = [appDelegate.PlacesArray objectAtIndex:indexPath.row];
        [appDelegate removePlace: PlaceObj];
        
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
    }   
}

The error is occurring on the line with [appDelegate removePlace: PlaceObj];.

The definitions of removePlace and deleteFromDatabase are as follows:

(void) removePlace:(Place *)PlaceObj 
{
    
    NSLog(@"remove place called");
    //Delete it from the database.
    [PlaceObj deleteFromDatabase];
    
    //Remove it from the array.
    [PlacesArray removeObject:PlaceObj];
}

-(void) deleteFromDatabase {
    if (delete_statment == nil) {
        const char *sql = "DELETE FROM places_table WHERE PlaceID=?";
        if (sqlite3_prepare_v2(database, sql, -1, &delete_statment, NULL) != SQLITE_OK) {
            NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
        }
    }
    
    sqlite3_bind_int(delete_statment, 1, PlaceID);
    int success = sqlite3_step(delete_statment);
    
    if (success != SQLITE_DONE) {
        NSAssert1(0, @"Error: failed to save priority with message '%s'.", sqlite3_errmsg(database));
    }
    
    sqlite3_reset(delete_statment);
}

I googled for the problem and found that it might be because I am accessing database from different threads. As thecode starts I am able to Read it from database. so Do I need to close something so that I can delete objects from database?

  • 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-25T00:04:00+00:00Added an answer on May 25, 2026 at 12:04 am

    You are not connected with SQLite Database.Check your database connection.

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

Sidebar

Related Questions

I have a problem with JPA (EclipseLink). I am not able to delete a
I want to be able to edit and delete resources myself, but not allow
I have an application where I show data from a database. In fact we
I am using jquery datatables to display data from a mysql database. When you
I have a selectmultiple choice widget that gets data from mysql database and displays
What's wrong with this code? I'm not able to validate 'data': $.post('http://localhost/do.php', function(data) {
I have a table model. I want to delete a row from a table.
I need to export data from a table in database A, then import it
My newest project is able to generate documents with information from a database. So
try 1 with sqlite and datastore path option WARNING 2011-07-13 05:01:06,169 datastore_file_stub.py:511] Could not

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.