I have two tables 'table1' and 'table_00'. I want to move some data from table1 to table_00
I have this method to do that:
- (void)moveData {
NSString *docsDir;
NSArray *dirPaths;
// Get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
// Build the path to the database file
databasePath = [[NSString alloc]
initWithString: [docsDir stringByAppendingPathComponent:
@"MYDB_3.db"]];
sqlite3_stmt *statement;
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &myDatabase) == SQLITE_OK) {
NSString *insertSQL=@"INSERT INTO TABLE_00 SELECT * FROM TABLE_1 WHERE ID=00000" ;
const char *insert_stmt = [insertSQL UTF8String];
//i am using only one 'insertSQL', i put two 'insertSQL' strings here for reference
//mulitple statements
NSString *insertSQL=@"INSERT INTO TABLE_00 SELECT * FROM TABLE_1 WHERE UTILITYID='00000';"
"INSERT INTO TABLE_01 SELECT * FROM TABLE_1 WHERE UTILITYID='00001';"
"INSERT INTO TABLE_02 SELECT * FROM TABLE_1 WHERE UTILITYID='00002';"
"INSERT INTO TABLE_03 SELECT * FROM TABLE_1 WHERE UTILITYID='00003';";
//this multiple query statement is not working
sqlite3_prepare_v2(myDatabase, insert_stmt, -1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE) {
NSLog(@"data moved");
} else {
NSLog(@"data not moved");
}
sqlite3_finalize(statement);
sqlite3_close(myDatabase);
}
After I call this method ,I can move the data by using a single query but, I am unable to move the data by using multiple statements.Could you please tell me why is this happening?
Thanks in advance.