Question about libpq and count(*)

From: moorleghen <moorleghen(at)gci-net(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Question about libpq and count(*)
Date: 1999-04-21 17:50:04
Message-ID: 371E0FCC.8E8746EF@gci-net.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

What I am trying to do is grab the total records in the database table
and add one so that the next record written gets a unquie id assigned.

this is the snippet of code I am currently using ----

res = PQexec(conn, "SELECT COUNT(*) FROM prob_entry");
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
printf("Content type: test/html\r\n\r\n");
printf("SELECT FAILED!\r\n");
printf("%s\r\n",PQerrorMessage(conn));
printf("Notify System Administrator\r\n");
exit_nicely(conn);
}

problem.prob_num = (int *)PQntuples(res);
PQclear(res);

The script dies with a premature end of script headers message, but if I
comment out the problem.prob_num = (int *)PQntuples(res); line it
functions properly.

problem.prob_num is defined int.

The rest of the database functions are working properly. I can INSERT
and even SELECT, but this still does not work.

Suggestions and comments welcome.

Regards,
Michael

Browse pgsql-interfaces by date

  From Date Subject
Next Message Brett W. McCoy 1999-04-21 18:57:13 Re: [INTERFACES] Possible error in libpg++ interface, date[time] fields.
Previous Message Pavel PaJaSoft Janousek 1999-04-21 17:37:33 Error in indexing?