X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BFBC1D1B503 for ; Wed, 24 Sep 2003 14:08:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 50312-05 for ; Wed, 24 Sep 2003 11:07:53 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 98D39D1B50F for ; Wed, 24 Sep 2003 11:07:49 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id h8OE6UiP003584; Wed, 24 Sep 2003 10:06:31 -0400 (EDT) To: "Vutharkar Goutham" Cc: pgsql-docs@postgresql.org Subject: Re: Select statement error !!!! In-reply-to: References: Comments: In-reply-to "Vutharkar Goutham" message dated "Wed, 24 Sep 2003 10:27:04 -0000" Date: Wed, 24 Sep 2003 10:06:30 -0400 Message-ID: <3583.1064412390@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/60 X-Sequence-Number: 2016 "Vutharkar Goutham" writes: > strcpy(query,"Select * from Udp_Table"); > res = PQexec(conn,query); > if(!res || PQresultStatus(res)! = PGRES_COMMAND_OK) > { > fprintf(stderr,"Select Failed.\n"); The result status from a successful SELECT will be PGRES_TUPLES_OK; PGRES_COMMAND_OK is only used for commands that do not return a tuple set. As commented nearby, it's not real clear that this query is succeeding, anyway. It would behoove you to print something more useful than "Select Failed" in your failure path ... see PQresStatus() and PQresultErrorMessage() for starters. regards, tom lane PS: this does not belong on pgsql-docs. pgsql-novice would be an appropriate forum for first-time questions.