pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Wolfe Whalen <wolfe@quios.net>
To: Brice André <brice@famille-andre.be>
To: pgsql-sql@postgresql.org
Subject: Re: DELETE...RETURNING problem with libpq
Date: Sat, 25 May 2013 05:00:41 -0700
Message-ID: <1369483241.9028.140661235555577.5F2DB852@webmail.messagingengine.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

Hi Brice,



I believe that you'll need PQcmdTuples - "Returns the number of rows
affected by the SQL command."



Watch out, it returns char* instead of int.  I believe it's supposed to
be used for the UPDATE ... RETURNING as well, but I'd double check on
that.



It's under "30.3.3. Retrieving Result Information for Other Commands"
in the 8.4 docs ("These functions are used to extract information
from PGresult objects that are not SELECT results."):

[1]http://www.postgresql.org/docs/8.4/static/libpq-exec.html



Let us know if that helps or if we should dig into it a little deeper.



Best regards,



Wolfe



--
Wolfe Whalen
wolfe@quios.net





On Sat, May 25, 2013, at 04:07 AM, Brice André wrote:

Dear all,

I am trying to translate a code written in php to C++. So, I am now
using lipq in order to access my postgresql database from C++.

As performance is an important feature, I am using prepared statements.

I have a SQL statement that performs a 'DELETE ... RETURNING ... '
stuff and I execute it from a prepared statement (using PQprepare and
PQexecPrepared). Now, when I execute this command, it properly deletes
requested row, but when I use command PQntuples, it returns 0, as if no
data was returned.

When I execute the same sql command from PgAdmin or from my old php
script (that did not use prepared statements), everything works fine.

Note that, in another part of my script, I use the same technique to
perform an 'UPDATE ... RETURNING' and it works properly...

Does anyone has an idea of what may fail and how I can solve this
problem ?

Regards,
Brice

PS : my postgresql server version is 8.4 and it is running on a Debian
server, if it may help.

References

1. http://www.postgresql.org/docs/8.4/static/libpq-exec.html

view thread (7+ messages)  latest in thread

Message-ID: <1369483241.9028.140661235555577.5F2DB852@webmail.messagingengine.com>
Permalink:  ../1369483241.9028.140661235555577.5F2DB852@webmail.messagingengine.com/
Also on:    postgresql.org/message-id/1369483241.9028.140661235555577.5F2DB852@webmail.messagingengine.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: wolfe@quios.net, brice@famille-andre.be
  Subject: Re: DELETE...RETURNING problem with libpq
  In-Reply-To: <1369483241.9028.140661235555577.5F2DB852@webmail.messagingengine.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox