如何使用 libpqxx 从数组中获取值?例如我有这样的表:
CREATE TABLE testTable
(
testArray integer[]
);
如何在 C++ 中获取具有这些值的 int 数组?
最佳答案
在 7.2 版本中,我使用 as_array
方法来解析整数数组:
list<unsigned long> found_messages;
pqxx::result res = db->execute(query);
auto arr = res[0][0].as_array();
pair<pqxx::array_parser::juncture, string> elem;
do
{
elem = arr.get_next();
if (elem.first == pqxx::array_parser::juncture::string_value)
found_messages.push_back(stoul(elem.second));
}
while (elem.first != pqxx::array_parser::juncture::done);
关于c++ - 如何使用 libpqxx 从数组中获取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33395425/