Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert statement not working for second table on same database in sqlite3 iphone
    primarykey
    data
    text
    <p>I have 2 tables on same database.</p> <p>For first table data is inserted successfully using below code:</p> <pre><code> NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:@"test.sqlite"]; if(sqlite3_open([databasePath UTF8String], &amp;database) == SQLITE_OK) { (sqlite3_exec(database, "BEGIN TRANSACTION", 0, 0, 0))==SQLITE_OK if ( sqlite3_exec(database, [insertStatement UTF8String], NULL, NULL, &amp;error) == SQLITE_OK) { NSLog(@"------- inserted here ----"); } else { NSLog(@"Error: %s", error); if(sqlite3_exec(database, "COMMIT", 0, 0, 0) ==SQLITE_OK){ NSLog(@"-------data sucessfully inserted "); } else { NSLog(@"-------data insertion failed"); sqlite3_exec(database, "ROLLBACK", 0, 0, 0); } (sqlite3_exec(database, "END TRANSACTION", 0, 0, 0)); sqlite3_close(database); } else { NSLog(@"-------sqlite open error "); } </code></pre> <p>The data is inserted successfully as I log.</p> <p>But when I use the same code for inserting into second table, no data is inserted I get log of </p> <pre><code>NSLog(@"-------data insertion failed") </code></pre> <p>I am also opening and closing database at each operation and releasing the handle.</p> <p>I think sqlite is not allowing me to write on database but don't understand why? Since I have closed database with earlier operation.</p> <p>Does anyone encountered same problem with no data insertion for 2nd table on same database file. </p> <p>Addt note: there are no syntax errors and if I don't insert on 1st table then insertion is done on 2nd table which is weird.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload