I am accessing the PostgreSQL server with libpq. My query looks like this ('Africa' is any string, column_2
and column_3
are both valid names and both queries return fine when executed from psql prompt):
SELECT column_2
FROM mytable
WHERE column_1='Africa' AND column_2 IS NOT NULL
LIMIT 1;
I get a result of 1 row and 1 column. Then some time later I change column_2
to column_3
and issue:
SELECT column_3
FROM mytable
WHERE column_1='Africa' AND column_3 IS NOT NULL
LIMIT 1;
Now PQnfields()
returns 1 as expected, But PQntuples
returns 0!
So now for some reason there are 0 rows, which of course breaks a call to data = PQgetvalue(resuls, 0, 0)
What is a possible source of error and why would it even return 1 column if there are no rows?