gpt4 book ai didi

ios - 需要正确的 Sql Stmt

转载 作者:行者123 更新时间:2023-11-29 04:06:12 26 4
gpt4 key购买 nike

我有 Sql 数据库,一切正常

  NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO CONTACTS where (modifiedAdress) VALUES (\"%@\")", hemaInsert];

我用它来插入,但我如何条件

只有我需要所说的Sql语句插入联系人列modifiedAdress Value hemainsert (condition hemaInsert = ID)

NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO CONTACTS where (modifiedAdress) VALUES (\"%@\")", hemaInsert];

最佳答案

- (void) InserRecorinTable:(NSString*) hemaInsert
{


int ret;
const char *sql = "insert into CONTACTS (modifiedAdress) values (?);";

sqlite3_stmt *insStmt = NULL;
if ( !insStmt )
if ( (ret = sqlite3_prepare_v2(_database, sql, -1, &insStmt, NULL)) != SQLITE_OK ) {}

// bind values
sqlite3_bind_text(insStmt, 1, hemaInsert, -1, SQLITE_TRANSIENT);

if ((ret = sqlite3_step(insStmt)) != SQLITE_DONE) {NSLog(@"error while inserting marker");}
sqlite3_reset(insStmt);


}

关于ios - 需要正确的 Sql Stmt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15174987/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com