Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用 SQLite 的编译语句将行插入表中:
rc = sqlite3_prepare(db, "INSERT INTO TABLE test VALUES (?,?,?,?)", -1, &stmt, 0); if( rc!=SQLITE_OK ) printf("%s", sqlite3_errmsg(db));
sqlite3_prepare返回 1,并sqlite3_errmsg返回:
sqlite3_prepare
sqlite3_errmsg
“在“表”附近:语法错误”
您不应该在查询中输入“TABLE”:
rc = sqlite3_prepare(db, "INSERT INTO test VALUES (?,?,?,?)", -1, &stmt, 0); if( rc!=SQLITE_OK ) printf("%s", sqlite3_errmsg(db));
命名您要插入的字段也是一个好习惯。这样,如果您向表中添加字段,您的查询就不会被破坏......
TABLE是保留关键字。为避免语法错误,必须使用方括号对其进行转义,
TABLE
INSERT INTO test VALUES (?,?,?,?)