PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

postgresql libpqxx Diverse query come una transazione

pqxx::work è un tipo di transazione predefinito.Usa più exec() metodo prima di commit() per eseguire più query in una transazione:

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();
...