0

I am creating a simple SQLite update in my Qt5/C++ program using QSqlQuery. When I execute the query below I get the error "Parameter count mismatch". But why?

QSqlQuery updateQuery;
updateQuery.prepare("UPDATE mytable SET m=:m WHERE r=:r AND u=:u LIMIT 1");
updateQuery.bindValue(":m", m);
updateQuery.bindValue(":r", r);
updateQuery.bindValue(":u", u);
sqlErrors = !updateQuery.exec();

Variables m, r, u are QString's. I have 3 parameters, and bind all three. Where's the mismatch? SO posts like this only refer to INSERT commands, but everything else applicable seems right.

Checking lastQuery() confirms the bind substitutions are not happening. I can also see that the prepare statement is failing (returning false) - yet it looks like valid SQL to me.

TSG
  • 4,242
  • 9
  • 61
  • 121

1 Answers1

1

It appears that the problem is the LIMIT word. Some SQLite packages are compiled without the SQLITE_ENABLE_UPDATE_DELETE_LIMIT flag. Which means you cannot add a limit to the update statement.

Seems like an odd feature to turn off by default (as distributed from base repo)...but that's it.

TSG
  • 4,242
  • 9
  • 61
  • 121