pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Guillaume Lelarge <guillaume@lelarge.info>
To: Brice André <brice@famille-andre.be>
Cc: Wolfe Whalen <wolfe@quios.net>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: DELETE...RETURNING problem with libpq
Date: Sun, 26 May 2013 08:51:19 +0200
Message-ID: <1369551079.3087.4.camel@localhost.localdomain> (raw )
In-Reply-To: <CAOBG12ms=mgLFaR7BD7s7LckCtcT7dSYX2bUYd2A2wOGN8LaiQ@mail.gmail.com >
References: <1369483241.9028.140661235555577.5F2DB852@webmail.messagingengine.com >
<CAOBG12ms=mgLFaR7BD7s7LckCtcT7dSYX2bUYd2A2wOGN8LaiQ@mail.gmail.com >
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
On Sat, 2013-05-25 at 14:49 +0200, Brice André wrote:
> Hi Wolfe,
>
> First, thanks for your help.
>
> I tried your code, but it does not work... the function returns a string :
> "0". When I check, this command properly modifies one row, as expected.
>
It works for me with PQntuples.
> I don't know if it may help, but just in case... The DELETE operation is
> not performed on a table : it is performed on a view. I have a rule on that
> view that, instead of performing a delete on the corresponding table,
> performs an update with table entry tagged as deleted (in a dedicated
> column of the table). This code (sql part) works for years and, when
> executing this command by other ways (php and pgadmin), it deletes and
> returns expected data. With libpq, it deletes, but does not return anything.
>
You'll find my test case attached. It's C code, not C++, but I guess it
won't be a big issue :)
It gives me this result:
$ ./example
connection OK
prepare OK
execute OK
ntuples: 81
cleanup OK
81 is the number of lines to delete. If I launch it another time, it
gives me 0 as all the rows have already been deleted.
Hope it helps.
--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
Attachments:
[application/x-compressed-tar] example.tgz (1.3K, ../1369551079.3087.4.camel@localhost.localdomain/2-example.tgz)
download
view thread (7+ messages) latest in thread
Message-ID: <1369551079.3087.4.camel@localhost.localdomain>
Permalink: ../1369551079.3087.4.camel@localhost.localdomain/
Also on: postgresql.org/message-id/1369551079.3087.4.camel@localhost.localdomain
copy link · copy postgr.es
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: guillaume@lelarge.info, brice@famille-andre.be, wolfe@quios.net
Subject: Re: DELETE...RETURNING problem with libpq
In-Reply-To: <1369551079.3087.4.camel@localhost.localdomain>
* 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