Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Calling server stored procedure using binding
Qt 6.11 is out! See what's new in the release blog

Calling server stored procedure using binding

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    silicomancer
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      silicomancer
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved