C++ 执行INSERT into数据库后如何获取插入行的fetch id?
我正在使用c++11和pqxx访问postgresql数据库,我需要插入行的id和标志,看是否成功。 执行INSERT into数据库后如何获取插入行的fetch id? 我曾试图在网上找到榜样,但没有成功C++ 执行INSERT into数据库后如何获取插入行的fetch id?,c++,postgresql,c++11,libpqxx,C++,Postgresql,C++11,Libpqxx,我正在使用c++11和pqxx访问postgresql数据库,我需要插入行的id和标志,看是否成功。 执行INSERT into数据库后如何获取插入行的fetch id? 我曾试图在网上找到榜样,但没有成功 work txn(*conn); txn.prepared("insert ")(person_name).exec(); txn.commit(); 工作txn(*conn); pqxx::result r=txn.prepared(“插入t(a,b,c)值(1,2,$1)返回id”)(
work txn(*conn);
txn.prepared("insert ")(person_name).exec();
txn.commit();
工作txn(*conn);
pqxx::result r=txn.prepared(“插入t(a,b,c)值(1,2,$1)返回id”)(person_name).exec();
提交();
int id=r[0][0].as();
插入。。。返回
?
work txn(*conn);
pqxx::result r = txn.prepared("insert into t (a,b,c) values (1,2,$1) returning id")(person_name).exec();
txn.commit();
int id = r[0][0].as<int>();