Re: [INTERFACES] Counting updates with libpq

From: Michael Meskes <meskes(at)postgreSQL(dot)org>
To: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] Counting updates with libpq
Date: 1999-03-08 19:34:42
Message-ID: 19990308203442.A2003@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)Meskes(at)gmx(dot)net | Use PostgreSQL!

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Henk Jan Barendregt 1999-03-08 19:39:10 create tables in empty database (libpq)
Previous Message Ulf Mehlig 1999-03-08 19:04:17 Re: [INTERFACES] pgaccess: window size and column resizing