#include "ExecQuery.h" #include #include ExecQuery::ExecQuery(const std::string& query, std::string& result) : pqxx::transactor<>("ExecQuery"), itsQuery(query), itsResult(result) { } void ExecQuery::operator()(argument_type& transaction) { itsPQResult = transaction.exec(itsQuery); } void ExecQuery::on_commit() { std::ostringstream oss; uint rows(itsPQResult.size()); uint cols(itsPQResult.columns()); oss << "_nrows = " << rows << std::endl; for (uint row = 0; row < rows; ++row) { for (uint col = 0; col < cols; ++col) { oss << "_row(" << row << ")." << itsPQResult[row][col].name() << " = " << itsPQResult[row][col].c_str() << std::endl; } } itsResult = oss.str(); }