Re: [INTERFACES] Counting updates with libpq - Mailing list pgsql-interfaces

From Michael Meskes
Subject Re: [INTERFACES] Counting updates with libpq
Date
Msg-id 19990308203442.A2003@gmx.net
Whole thread Raw
In response to Re: [INTERFACES] Counting updates with libpq  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-interfaces
On Mon, Mar 08, 1999 at 10:47:38AM -0500, Tom Lane wrote:
> No, I'm afraid *you* are incorrect: a test program like
>
>     res = PQexec(conn, "INSERT INTO test SELECT * FROM test");
>     if (PQresultStatus(res) != PGRES_COMMAND_OK)
>     {
>         fprintf(stderr, "INSERT command failed\n");
>         PQclear(res);
>         exit_nicely(conn);
>     }
>
>     printf("INSERT result PQntuples = %d\n", PQntuples(res));
>     printf("INSERT result PQcmdTuples = %s\n", PQcmdTuples(res));
>
> produces the expected results (ntuples = 0, cmdTuples = number of
> inserted rows) for either variant of INSERT.

Strange. Have to check my code again. ... Argh! I'm stupid. I just checked
via pattern matching and found only the position where the return value was
PGRES_TUPLES_OK. In this case I use PQntuples(). If the result was
PGRES_COMMAND_OK I do use PQcmdTuples. So I guess that explains it. :-)

Michael
--
Michael Meskes                         | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
Email: Michael.Meskes@gmx.net          | Use PostgreSQL!

pgsql-interfaces by date:

Previous
From: "Brett W. McCoy"
Date:
Subject: Re: [INTERFACES] Perl Interface(Pg.pm) -- How to free $result
Next
From: Eildert Groeneveld
Date:
Subject: Bug in sortin routine?