How can I get values from array using libpqxx? For Example I have table like this:
CREATE TABLE testTable
(
testArray integer[]
);
How do I get int array with these values in C++?
In the version 7.2 I am using the as_array method to parse an array of integers:
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With