Re: Regarding PL/SQL with C - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: Regarding PL/SQL with C
Date
Msg-id 20060225151852.GA58695@winnie.fuhr.org
Whole thread Raw
In response to Regarding PL/SQL with C  (Krishnaprasad <k.krishna@hcl.in>)
Responses Re: Regarding PL/SQL with C
List pgsql-novice
On Sat, Feb 25, 2006 at 02:03:51PM +0530, Krishnaprasad wrote:
> I have written code for connecting to a database and select one row and
> just print it out.. Iam able to make a connection with the databse. But
> after connection it is showing that select query failed.... but if iam
> directly selecting through PL/SQL prompt iam able to do the same.......

You're connecting to the database thusly:

>   conn = PQconnectStart("user=postgres,dbname=krishna");

Parameters in the connect string should be space-separated, not
comma-separated.  The select is probably failing because the connect
failed; you're not seeing the connection failure because you're
calling PQconnectStart to make a nonblocking connection and you're
not waiting for the connection to complete before making the query.
Unless you need a nonblocking connection use PQconnectdb instead:

    conn = PQconnectdb("user=postgres dbname=krishna");

Then check for CONNECTION_OK, not CONNECTION_MADE.

When an operation has failed, you can use PQerrorMessage or
PQresultErrorMessage to display the reason.

--
Michael Fuhr

pgsql-novice by date:

Previous
From: "Juan Ravera"
Date:
Subject: UNSUSCRIBE
Next
From:
Date:
Subject: tsearch2: rebuilding of fulltext index