pg.ddx.io pgsql-interfaces@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: moorleghen <moorleghen@gci-net.com>
To: pgsql-interfaces@postgresql.org
Subject: Question about libpq and count(*)
Date: Wed, 21 Apr 1999 10:50:04 -0700
Message-ID: <371E0FCC.8E8746EF@gci-net.com> (raw)
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
Message-ID: <371E0FCC.8E8746EF@gci-net.com> Permalink: ../371E0FCC.8E8746EF@gci-net.com/ Also on: postgresql.org/message-id/371E0FCC.8E8746EF@gci-net.com ·
reply
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Reply to all the recipients using the --to and --cc options: reply via email To: pgsql-interfaces@postgresql.org Cc: moorleghen@gci-net.com Subject: Re: Question about libpq and count(*) In-Reply-To: <371E0FCC.8E8746EF@gci-net.com> * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox