[Qt-interest] Know the progress of a query with QODBC

Robert Hairgrove evorgriahr at hispeed.ch
Wed Feb 11 14:02:28 CET 2009


Jesús Fernández wrote:
> Hi,
> 
> I have a stored procedure in the database used for submit images to the 
> database, this images are too big, how can I know the progress of the 
> transfer if I'm using the SQL Driver QODBC.
> 

This is a very database-specific issue. If your DBMS supports 
asynchronous query processing, you might be able to do it through native 
ODBC function calls; however, I don't believe there is an interface in 
QSqlDatabase to poll a running query.

Even if you could start the query to run asynchronously, 
QSqlQuery::exec() would return immediately; otherwise, it would not 
return until all the images are loaded. As a work-around, assuming you 
can run asynchronous queries at all, I would have the stored procedure 
update a status column in the database and commit work every so often, 
then poll the status from the application by querying that column 
periodically.

Depending on your database, it might be necessary to set the 
asynchronous option before connecting to the database, in which case you 
would have to connect via ODBC before constructing the QSqlDatabase 
object (see the documentation for QSqlDriver and 
QSqlDatabase::addDatabase() for details).



More information about the Qt-interest-old mailing list