August 2, 2011

reactive reactive
Lab Rat
39 posts

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


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:

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

BEGIN SET y = 11;

The code is:

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

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

Thanks for any advice!

4 replies

August 3, 2011

alexisdm alexisdm
Lab Rat
142 posts

You should use the code from:

August 3, 2011

reactive reactive
Lab Rat
39 posts

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

August 3, 2011

mlong mlong
Robot Herder
1537 posts

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


Senior Software Engineer
AccuWeather Enterprise Solutions
/* My views and opinions do not necessarily reflect those of my employer.  Void where prohibited. */

August 3, 2011

reactive reactive
Lab Rat
39 posts

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

  ‹‹ [Solved]Qt and FreeBSD      Qt::key of / ››

You must log in to post a reply. Not a member yet? Register here!