postgresql libpqxx将多个查询作为一个事务处理
是否可以执行一个包含多个查询的事务,例如在表1中插入smth和在表2中插入smth?我如何实现这一点?我使用postgresql libpqxx将多个查询作为一个事务处理,postgresql,libpqxx,Postgresql,Libpqxx,是否可以执行一个包含多个查询的事务,例如在表1中插入smth和在表2中插入smth?我如何实现这一点?我使用libpqxx与数据库交互,并期望得到与此相关的答案。谢谢。是默认的交易类型。 在commit()之前使用multipleexec()方法在一个事务中运行多个查询: using namespace pqxx; ... connection c("dbname=test user=postgres hostaddr=127.0.0.1"); work w(c); w.exec("
libpqxx
与数据库交互,并期望得到与此相关的答案。谢谢。是默认的交易类型。
在commit()
之前使用multipleexec()
方法在一个事务中运行多个查询:
using namespace pqxx;
...
connection c("dbname=test user=postgres hostaddr=127.0.0.1");
work w(c);
w.exec("create table test_xx (id int primary key)");
w.exec("insert into test_xx values (1)");
w.commit();
...