diff --git a/db_bridge/postgresql_db.cpp b/db_bridge/postgresql_db.cpp --- a/db_bridge/postgresql_db.cpp +++ b/db_bridge/postgresql_db.cpp @@ -4,6 +4,7 @@ */ #include +#include PostgreSQL_DB::PostgreSQL_DB (std::string srv, std::string usr, std::string pwd, std::string db) { @@ -43,7 +44,8 @@ Abstract_DB::DB_ROW vec; Abstract_DB::DB_RESULT rows; PGresult *res; - int i, j, nFields; + int i, j; + int nFields, nRows; /* * send SQL query @@ -51,13 +53,14 @@ res = PQexec (conn, sql_string.c_str ()); nFields = PQnfields (res); + nRows = PQntuples (res); - std::cout << "Die Abfrage ergab " << nFields << " Zeilen." << std::endl; + std::cout << "Die Abfrage hat " << nFields << " Spalte(n) und " << nRows << " Reihe(n)." << std::endl; /* * push everything into a vector< vector > */ - for (i = 0; i < PQntuples (res); i++) { + for (i = 0; i < nRows; i++) { for (j = 0; j < nFields; j++) { vec.push_back (PQgetvalue (res, i, j)); }