[Qt-interest] QSqlQuery::numRowsAffected

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Sat Jun 27 04:33:26 CEST 2009


Hi Rick, 

I don't know anything about Postgres.  Maybe the Qt postgres driver only
gets the rows updated from the lower level interface when the query does not
return data?  What does the Postgres interactive query tools say when you
run the same query manually? 

Have a look at the Qt driver source for where rows affected comes from.  You
might be able to change the source, or you may find the lower level
interfaces work the same way - and it is a design flaw! 

Hope that helps, 

Tony


> On Monday 22 June 2009 3:20:04 pm Rick Vernam wrote:
> > I have very simple update query, which also returns data.
> > In Postgres' psql, I run:
> > update sometable set somefield = somevalue where 
> somecriteria=whatever
> > returning someothervalue;
> >
> > When I run this query via the QPSQL driver, 
> sometable.somefield is indeed
> > updated to somevalue, however QSqlQuery::numRowsAffected 
> returns zero.
> >
> > If I run the query without the returning clause, then I get 
> a valid result
> > from QSqlQuery::numRowsAffected.
> >
> > So is this the expected behavior?
> >
> > Thanks,
> > -Rick





More information about the Qt-interest-old mailing list