Re: [SQL] DELETE...RETURNING problem with libpq

2013-05-25 Thread Guillaume Lelarge
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'

Re: [SQL] Advice on re-writing a SELECT query.

2013-05-25 Thread Marc Mamin
I have a query like this: > >SELECT >lpt_titulo AS tmt_titulo, >tmd_nombre AS tmt_nombre, >tmd_album AS tmt_album >SUM(lpt_puntos) AS tmt_puntos, >lpt_fuente AS tmt_fuente >FROM listas_pre_titulos, temp_lista_titulos >WHERE >listas_pre_titulos.lpt_tipo = 3 AND >listas_pre_titulos.lpt_titulo <> temp

[SQL] Advice on re-writing a SELECT query.

2013-05-25 Thread JORGE MALDONADO
I have a query like this: SELECT lpt_titulo AS tmt_titulo, tmd_nombre AS tmt_nombre, tmd_album AS tmt_album SUM(lpt_puntos) AS tmt_puntos, lpt_fuente AS tmt_fuente FROM listas_pre_titulos, temp_lista_titulos WHERE listas_pre_titulos.lpt_tipo = 3 AND listas_pre_titulos.lpt_titulo <> temp_lista_titu

Re: [SQL] DELETE...RETURNING problem with libpq

2013-05-25 Thread Brice André
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. I don't know if it may help, but just in case... The DELETE operation is not performed on a table : it is perf

Re: [SQL] DELETE...RETURNING problem with libpq

2013-05-25 Thread Wolfe Whalen
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 Re

Re: [SQL] reduce many loosely related rows down to one

2013-05-25 Thread Marc Mamin
> > Von: pgsql-sql-ow...@postgresql.org [pgsql-sql-ow...@postgresql.org]" im > Auftrag von "Bill MacArthur [webmas...@dhs-club.com] > Gesendet: Samstag, 25. Mai 2013 09:19 > An: pgsql-sql@postgresql.org > Betreff: [SQL] reduce many loosely related rows dow

[SQL] DELETE...RETURNING problem with libpq

2013-05-25 Thread Brice André
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 exec

[SQL] reduce many loosely related rows down to one

2013-05-25 Thread Bill MacArthur
Here is a boiled down example of a scenario which I am having a bit of difficulty solving. This is a catchall table where all the rows are related to the "id" but are entered by different unrelated processes that do not necessarily have access to the other data bits. CREATE TABLE test (