Re: PGExec returns error without any comment - Mailing list pgsql-interfaces

From Michael Fuhr
Subject Re: PGExec returns error without any comment
Date
Msg-id 20060928133741.GA15280@winnie.fuhr.org
Whole thread Raw
In response to PGExec returns error without any comment  (erkan kolemen <erkankolemen@yahoo.com>)
List 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
commandsthat can never return rows (INSERT, UPDATE, etc.).
 

-- 
Michael Fuhr


pgsql-interfaces by date:

Previous
From: erkan kolemen
Date:
Subject: PGExec returns error without any comment
Next
From: "Jon Earle"
Date:
Subject: Extracting client code