number of affected rows in pgtcl

Started by Christian Traberover 23 years ago4 messagesgeneral
Jump to latest
#1Christian Traber
christian@traber-net.de

Hi,

Is there a way to get the number of affected rows of a non select statement
from libpgtcl?

(Like PQcmdTuples in libpq.)

Thanks,
Christian

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christian Traber (#1)
Re: number of affected rows in pgtcl

Christian Traber <christian@traber-net.de> writes:

Is there a way to get the number of affected rows of a non select statement
from libpgtcl?

Doesn't pg_result provide a way to get that?

regards, tom lane

#3Christian Traber
christian@traber-net.de
In reply to: Christian Traber (#1)
Re: number of affected rows in pgtcl

Is there a way to get the number of affected rows of a non select statement
from libpgtcl?

Doesn't pg_result provide a way to get that?

No, pg_result -numTuples only returns the number of found rows of a
select statement.
On update, delete -numTuples returns 0.

Regards,
Christian

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christian Traber (#3)
Re: number of affected rows in pgtcl

Christian Traber <christian@traber-net.de> writes:

Doesn't pg_result provide a way to get that?

No, pg_result -numTuples only returns the number of found rows of a
select statement.

Um, you're right; there's no interface to PGcmdTuples in pg_result.
Perhaps there should be. But the short-term answer is to use pg_execute
instead of pg_exec. See
http://developer.postgresql.org/docs/postgres/pgtcl-pgexecute.html
(this unaccountably escaped being documented before 7.3, but it's
been there since 7.1 or so).

regards, tom lane