I am using a pre processor. Postgres provides a program called epcg which, is postgres's version of something called Embedded SQL.
I have to work within this framework, as much as the PGConn and PQconnectdb objects might be easier or better to use I cannot use these.
Thank you for trying, but I am looking for answer that is within Postgres's Embedded SQL Preprocessor.
Main Topics
Browse All Topics





by: itsmeandnobodyelsePosted on 2009-10-12 at 00:26:03ID: 25549132
You should have a connect string like
;
char connectstring[] = "host=localhost port=5432 user=postgres password=password dbname='TESTDB'";
and connect like
PGconn * conninfo = NULL;
conninfo = PQconnectdb(connectstring)
Finally check for error like
if (PQstatus(conninfo) == CONNECTION_BAD)
{
/* error handling */
}
else if (PQstatus(conninfo) == CONNECTION_OK)
{
/* ok */
}
else
{
/* shouldn't occur */
}