Re: DELETE...RETURNING problem with libpq - Mailing list pgsql-sql

From Guillaume Lelarge
Subject Re: DELETE...RETURNING problem with libpq
Date
Msg-id 1369551079.3087.4.camel@localhost.localdomain
Whole thread Raw
In response to Re: DELETE...RETURNING problem with libpq  (Brice André <brice@famille-andre.be>)
Responses Re: DELETE...RETURNING problem with libpq
List pgsql-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

Attachment

pgsql-sql by date:

Previous
From: Marc Mamin
Date:
Subject: Re: Advice on re-writing a SELECT query.
Next
From: Brice André
Date:
Subject: Re: DELETE...RETURNING problem with libpq