Re: Number of updated rows with LibPQ

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Dominique Devienne <ddevienne(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Number of updated rows with LibPQ
Date: 2022-10-05 18:17:08
Message-ID: 2433846.1664993828@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> writes:
> On Wed, 2022-10-05 at 16:38 +0200, Dominique Devienne wrote:
>> For selects, I have [PQnTuples][2], but what to do on INSERT, UPDATE, DELETE?
>> Parse the result of PQcmdTuples myself??? If so, what's the 0 in the
>> INSERT below?

> Yes, you have to use PQcmdTuples(), and you have to convert the string to an integer.
> But don't worry: the result will *not* be "INSERT 0 5", it will be just "5", so
> you won't have to parse anything.

Yeah, just applying atoi() or atol() to the result should be enough.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josef Šimánek 2022-10-05 21:39:24 Re: Postgres calendar?
Previous Message Christophe Pettus 2022-10-05 17:31:52 Re: Replication between Master PostgreSQL database version 9.6.1 and Standby/Slave PostgreSQL database version 10.17.