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

Re: Select statement error !!!!

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Vutharkar Goutham" <goutham4u(at)hotmail(dot)com>
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: Select statement error !!!!
Date: 2003-09-24 14:06:30
Message-ID: 3583.1064412390@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-docs
"Vutharkar Goutham" <goutham4u(at)hotmail(dot)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.

In response to

pgsql-docs by date

Next:From: Vutharkar GouthamDate: 2003-09-24 14:48:22
Subject: Re: Select statement error !!!!
Previous:From: Oliver ElphickDate: 2003-09-24 11:00:49
Subject: Re: Select statement error !!!!

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group