Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: PGExec returns error without any comment



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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group