0

Basically I have to enter all textfield values in database then have to use for sending to webservice. So when the one column details send to service then have to delete that column. I have done this:

-(void)deleteTableDataFromSavedDataTable:(NSString *)lastID {
    NSString *sql_str=[NSString stringWithFormat:@"DELETE FROM FormInfoValues where Phone = %@",lastID];

    const char *sql = [sql_str UTF8String];

    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK)
    {
        NSLog(@"sql delete statement is ");

        sqlite3_stmt *deleteStmt;
        if(sqlite3_prepare_v2(database, sql, -1, &deleteStmt, NULL) == SQLITE_OK)
        {
            NSLog(@"sql delete statement is %@", deleteStmt);
            if(sqlite3_step(deleteStmt) != SQLITE_DONE )
            {
                NSLog( @"Error: %s", sqlite3_errmsg(database) );
            }
            else
            {
                NSLog( @"row id = %lld", (sqlite3_last_insert_rowid(database)+1));
                NSLog(@"No Error");
            }
        }
        sqlite3_finalize(deleteStmt);
    }
    sqlite3_close(database);
}

but its not deleting after sending. Why its not calling? give me ideas..

4

1 回答 1

1

很可能我没有正确理解您的问题 - 所以如果是这样,我提前道歉。

关于:“......然后必须删除该列。”

-- 如果要清除列中的数据(通过将其设置为零、空字符串或 NULL),则需要在 SQL 中使用 UPDATE 命令。DELETE 命令总是删除 ROWS。

-- 如果你真的必须从表的模式中删除一列,你必须在 sqlite 中创建一个新表。(Sqlite 允许您通过 ALTER TABLE 命令添加列,而其他一些数据库也允许您使用 ALTER TABLE 删除列。)您可以通过以下方式快速复制表(没有约束等):

CREATE TABLE MyOutput as SELECT a,b,d,f,h,z from MyOriginal;

-- 如果您的输出是由 SELECT 语句创建的,请避免使用“*”并仅指定要包含的列。

于 2012-06-14T18:40:15.700 回答