SQLITE(C / C ++接口) - 如何提交事务 [英] SQLITE (C/C++interface) - How to commit a transaction

查看:964
本文介绍了SQLITE(C / C ++接口) - 如何提交事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用sqlite的C / C ++接口。

I am using sqlite c/c++ interface.

现在这里是我的方案 -

Now here is my scenario -

我有3个表(相关表)说A,B,C。

I have 3 tables (related tables) say A, B, C.

现在,有一个名为函数设置,它得到一些输入,并根据输入
行插入这三张表。 (有时也可以是在一个表的更新)

Now, there is a function called Set, which get some inputs and based on the inputs inserts rows into these three tables. (sometimes it can be an update in one of the tables)

现在我需要两件事情。

一,我不希望自动提交功能。基本上,我想每1000调用设置功能

One, i dont want autocommit feature. Basically I would like to commit after every 1000 calls to Set function

其次,设置功能本身,如果我发现插入到两个表之后,第三个插入失败,我已经恢复,这些特定的变化在设置函数调用。

Secondly, within the set function itself, if i find that after inserting into two tables, the third insert fails, then i have to revert, those particular changes in that Set function call.

现在我没有看到任何接触功能sqlite3_commit。我只看到一个函数调用sqlite3_commit_hook(),这是在文档中略有差异。
是否有暴露用于此目的的功能?或者什么是实现这一目标的行为方式?

Now i dont see any sqlite3_commit function exposed. I only see a function called sqlite3_commit_hook() which is slightly diff in documentation. Are there any function exposed for this purpose? or What is the way to achieve this behaviour?

您可以帮我这样做的最好的办法。

Can you help me with the best approach of doing this.

问候,
阿琼

推荐答案

可以使用开始,提交和C / C ++ code里面ROLLBACK SQL语句?

can you use BEGIN, COMMIT and ROLLBACK sql statements inside the C/C++ code?

这篇关于SQLITE(C / C ++接口) - 如何提交事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆