pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: erkan kolemen <erkankolemen@yahoo.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: PGExec returns error without any comment
Date: Thu, 28 Sep 2006 07:37:41 -0600
Message-ID: <20060928133741.GA15280@winnie.fuhr.org> (raw)
In-Reply-To: <20060928121611.21391.qmail@web58304.mail.re3.yahoo.com>
References: <20060928121611.21391.qmail@web58304.mail.re3.yahoo.com>

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



view thread (3+ messages)  latest in thread

Message-ID: <20060928133741.GA15280@winnie.fuhr.org>
Permalink:  ../20060928133741.GA15280@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20060928133741.GA15280@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: mike@fuhr.org, erkankolemen@yahoo.com
  Subject: Re: PGExec returns error without any comment
  In-Reply-To: <20060928133741.GA15280@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox