[Qt-interest] QSqlQuery::numRowsAffected

Rick Vernam rickv at hobi.com
Sat Jun 27 09:34:49 CEST 2009


On Friday 26 June 2009 9:33:26 pm Tony Rietwyk wrote:
> 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?
Returns requested row(s), then says number of records updated. :-)

>
> Have a look at the Qt driver source for where rows affected comes from. 
If I become motivated enough, this is where I would start, too...

> 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
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list