Re: Select statement error !!!! - Mailing list pgsql-docs

From Tom Lane
Subject Re: Select statement error !!!!
Date
Msg-id 3583.1064412390@sss.pgh.pa.us
Whole thread Raw
In response to Select statement error !!!!  ("Vutharkar Goutham" <goutham4u@hotmail.com>)
List pgsql-docs
"Vutharkar Goutham" <goutham4u@hotmail.com> 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.

pgsql-docs by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: Select statement error !!!!
Next
From: "Vutharkar Goutham"
Date:
Subject: Re: Select statement error !!!!