Received: from mail.gci-net.com (mail.gci-net.com [208.2.166.101]) by hub.org (8.9.3/8.9.1) with SMTP id NAA90080 for ; Wed, 21 Apr 1999 13:46:29 -0400 (EDT) (envelope-from moorleghen@gci-net.com) Received: from ip161.tuc167.gci-net.com (ip161.tuc167.gci-net.com [208.2.167.161]) by mail.gci-net.com (NTMail 3.03.0017/1d.aawt) with ESMTP id za360489 for ; Wed, 21 Apr 1999 10:47:10 -0700 Message-ID: <371E0FCC.8E8746EF@gci-net.com> Date: Wed, 21 Apr 1999 10:50:04 -0700 From: moorleghen X-Mailer: Mozilla 4.5 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: Question about libpq and count(*) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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