Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在C/C++;?_C++_Sql_C_Sqlite_Transactions - Fatal编程技术网

C++ 如何在C/C++;?

C++ 如何在C/C++;?,c++,sql,c,sqlite,transactions,C++,Sql,C,Sqlite,Transactions,我正在使用sqlite c/c++接口 我有3个表(相关表),比如A、B、C。现在,有一个名为Set的函数,它获取一些输入,并根据输入将行插入这三个表中。(有时可能是其中一个表中的更新) 现在我需要两样东西。第一,我不想要自动提交功能。基本上,我希望在每1000次调用Set函数后提交 其次,在set函数本身中,如果我发现在插入两个表之后,第三次插入失败,那么我必须恢复set函数调用中的那些特定更改 现在我没有看到任何sqlite3_提交函数公开。我只看到一个名为sqlite3_commit_ho

我正在使用sqlite c/c++接口

我有3个表(相关表),比如A、B、C。现在,有一个名为Set的函数,它获取一些输入,并根据输入将行插入这三个表中。(有时可能是其中一个表中的更新)

现在我需要两样东西。第一,我不想要自动提交功能。基本上,我希望在每1000次调用Set函数后提交

其次,在set函数本身中,如果我发现在插入两个表之后,第三次插入失败,那么我必须恢复set函数调用中的那些特定更改

现在我没有看到任何sqlite3_提交函数公开。我只看到一个名为sqlite3_commit_hook()的函数,它在文档中稍有不同

是否为此目的公开了任何功能?或者,实现这种行为的方法是什么

你能帮我找到最好的方法吗。

你可以分别使用并通过“开始交易”和“结束交易”

// 'db' is the pointer you got from sqlite3_open*
sqlite3_exec(db, "BEGIN TRANSACTION;", NULL, NULL, NULL);
// Any (modifying) SQL commands executed here are not committed until at the you call:
sqlite3_exec(db, "END TRANSACTION;", NULL, NULL, NULL);

这些SQL命令有同义词(如
COMMIT
而不是
END TRANSACTION
)。作为参考,这里是。

您不能只执行
开始
提交
查询吗?我们应该使用
结束事务
还是
提交
?它们是相同的<代码>结束事务只是
提交
-