| От | moorleghen |
|---|---|
| Тема | Question about libpq and count(*) |
| Дата | |
| Msg-id | 371E0FCC.8E8746EF@gci-net.com обсуждение |
| Список | 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
В списке pgsql-interfaces по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера