Calling server stored procedure using binding



  • I am trying to call a MySQL server stored procedure using Qt. The procedure returns multiple rows of data I want to retrieve.

    The first snippet I tried works fine:

    QSqlQuery query("CALL GetOrderItems(323)", dataBase);
    qDebug() << query.first();

    It also returns the desired data and query.first() is true like expected.

    Then I tried to insert the parameter using parameter binding like the Qt documentation proposes. I tried the following snippets. The first uses index placeholder the second keyword placeholder.

    QSqlQuery query(dataBase);
    qDebug() << query.prepare("CALL GetOrderItems(?)");
    query.bindValue(0, 323);
    qDebug() << query.exec();
    qDebug() << query.first();

    QSqlQuery query(dataBase);
    qDebug() << query.prepare("CALL GetOrderItems(:myparam)");
    query.bindValue(":myparam", 323);
    qDebug() << query.exec();
    qDebug() << query.first();

    Both of these queries execute fine. But query.first() returns false so I don't know how to get the results.

    Can I get the result from the binding queries in some way? Why doesn't this work?



  • Hm. Seems this is simply not supported. Binding values in Qt/MySQL are almost uselss :-(

    This is my original thread in stackoverflow: http://stackoverflow.com/questions/26448906/calling-server-stored-procedure-using-binding


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.