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

From Tom Lane
Subject Re: [INTERFACES] Counting updates with libpq
Date
Msg-id 21236.920823639@sss.pgh.pa.us
Whole thread Raw
In response to Re: [INTERFACES] Counting updates with libpq  (Michael Meskes <meskes@postgreSQL.org>)
Responses Re: [INTERFACES] Counting updates with libpq  (Michael Meskes <meskes@postgresql.org>)
List pgsql-interfaces
Michael Meskes <meskes@postgresql.org> writes:
>>>> Is it possible to get number of updated records using the PQexec command
>>>> and processing the PQresult record?
>>
>> See PQcmdTuples() ...

> For ecpg I've beed using PQntuples(). Is it the same function?

No.  PQntuples() is the number of rows in the returned result.  It will
always be zero if the SQL command was not SELECT (or FETCH).

PQcmdTuples() is just a dumb little function that looks at the command
status string (the same thing psql prints at the end of a query) and
pulls out the number that appears in "UPDATE n" or "DELETE n" or
"INSERT oid n".  Since the questioner asked about updated records,
I assumed that was the number he wanted.

            regards, tom lane

pgsql-interfaces by date:

Previous
From: Michael Meskes
Date:
Subject: Re: [INTERFACES] Counting updates with libpq
Next
From: Nitin Mule
Date:
Subject: DBD::Pg ->Error in 'make test'