Re: [INTERFACES] Counting updates with libpq

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [INTERFACES] Counting updates with libpq
Date: 1999-03-07 16:20:39
Message-ID: 21236.920823639@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Michael Meskes <meskes(at)postgresql(dot)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

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Nitin Mule 1999-03-07 17:09:32 DBD::Pg ->Error in 'make test'
Previous Message Anatoly K. Lasareff 1999-03-07 09:56:05 Re: [ADMIN] date & time