| From: | Michael Fuhr <mike(at)fuhr(dot)org> |
|---|---|
| To: | erkan kolemen <erkankolemen(at)yahoo(dot)com> |
| Cc: | pgsql-interfaces(at)postgresql(dot)org |
| Subject: | Re: PGExec returns error without any comment |
| Date: | 2006-09-28 13:37:41 |
| Message-ID: | 20060928133741.GA15280@winnie.fuhr.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-interfaces |
On Thu, Sep 28, 2006 at 05:16:10AM -0700, erkan kolemen wrote:
> res = PQexec(conn, "select * from lists;");
> if (PQresultStatus(res) != PGRES_COMMAND_OK)
You're checking for the wrong result status. Here are some excerpts
from the libpq documentation:
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).
Note that a SELECT command that happens to retrieve zero rows still
shows PGRES_TUPLES_OK. PGRES_COMMAND_OK is for commands that can
never return rows (INSERT, UPDATE, etc.).
--
Michael Fuhr
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jon Earle | 2006-09-28 14:08:11 | Extracting client code |
| Previous Message | erkan kolemen | 2006-09-28 12:16:10 | PGExec returns error without any comment |