当前位置: 代码迷 >> 综合 >> pqxx::tuple::reference类型转换为其他数据类型
  详细解决方案

pqxx::tuple::reference类型转换为其他数据类型

热度:82   发布时间:2023-12-17 09:47:47.0

 转换格式见下面例子中展示:

pqxx::work w(conn);//创建一个事务对象,conn为连接的数据库
pqxx::result res=w.exec(sql);//sql为SQL语句//将查询结果转为其他数据类型格式展示
for(pqxx::result::const_iterator row=res.begin();row!=res.end();++row)
{cout<<"int型:"<<row[0].as<int>()<<endl;   //将结果转为int型cout<<"float型:"<<row[1].as<float>()<<endl; //将结果转为float型cout<<"double型:"<<row[2].as<double>()<<endl; //将结果转为double型cout<<"string型:"<<row[3].as<string>()<<endl; //将结果转为string型
}

 

  相关解决方案