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. [SOLVED] Getting the OUT of a MySQL stored procedure?
QtWS25 Last Chance

[SOLVED] Getting the OUT of a MySQL stored procedure?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 9.5k Views
  • 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.
  • R Offline
    R Offline
    reactive
    wrote on last edited by
    #1

    Hi, I'm trying to get the value of a OUT variable from a stored procedure with no luck.
    I'm using the code from the docs: http://doc.qt.nokia.com/4.7/qsqlquery.html#approaches-to-binding-values

    I'm new to SPs so this is my test one:

    PROCEDURE abc(IN x INT, OUT y INT)
    BEGIN
    SET y = 11;
    END

    The code is:

    @
    QSqlQuery query (myDB);
    query.prepare("CALL abc(?, ?)");
    query.bindValue(0, "7");
    query.bindValue(1, 0, QSql::Out);
    query.exec();
    int i = query.boundValue(1).toInt(); // i is 65
    @

    I get this error: OUT or INOUT argument 2 for routine blah.abc is not a variable or NEW pseudo-variable in BEFORE trigger QMYSQL3

    Thanks for any advice!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexisdm
      wrote on last edited by
      #2

      You should use the code from:
      http://doc.qt.nokia.com/latest/sql-driver.html#qmysql

      1 Reply Last reply
      0
      • R Offline
        R Offline
        reactive
        wrote on last edited by
        #3

        Thanks, Alexis. That's exactly what I was looking for.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          Be sure and change the thread title to add a [Solved]. Thanks!

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            reactive
            wrote on last edited by
            #5

            No problem! I looked for the "solved" button like at the Java forums. I didn't realize I had to edit the title manually.

            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