1

Is there somebody who can explain to me, why in postgresql libpq there are different methods of checking, whether an sql command was executed successfully or not (function "PQexec").

If your sql command in "PQexec" was a command returning no data (for instance an insert statement) you have to write

 if (PQresultStatus(res) != PGRES_COMMAND_OK)

and if your sql command in "PQexec" was a command returning data (for instance a fetch statement) you have to write

if (PQresultStatus(res) != PGRES_TUPLES_OK)

Information

http://www.postgresql.org/docs/9.0/static/libpq-exec.html

PGRES_COMMAND_OK: Successful completion of a command returning no data.
PGRES_TUPLES_OK:  Successful completion of a command returning data (such as a SELECT or SHOW).

Why is this?

It would be clearer, if there would be only one method to check the executing status of "PQexec".

Thanks alot in advance

Wolfgang Adamec
  • 8,374
  • 12
  • 50
  • 74

0 Answers0