Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id DB5729FA259 for ; Thu, 28 Sep 2006 10:37:51 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 56262-05 for ; Thu, 28 Sep 2006 13:37:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 0CA269FA251 for ; Thu, 28 Sep 2006 10:37:47 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id k8SDbgMU084537 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Sep 2006 07:37:45 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.8/8.13.8) with ESMTP id k8SDbgpf015398; Thu, 28 Sep 2006 07:37:42 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.8/8.13.8/Submit) id k8SDbfJD015397; Thu, 28 Sep 2006 07:37:41 -0600 (MDT) (envelope-from mfuhr) Date: Thu, 28 Sep 2006 07:37:41 -0600 From: Michael Fuhr To: erkan kolemen Cc: pgsql-interfaces@postgresql.org Subject: Re: PGExec returns error without any comment Message-ID: <20060928133741.GA15280@winnie.fuhr.org> References: <20060928121611.21391.qmail@web58304.mail.re3.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060928121611.21391.qmail@web58304.mail.re3.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=SPF_PASS, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200609/32 X-Sequence-Number: 6277 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