I just want to run this type of procedure from Qt side:
DROP PROCEDURE IF EXISTS get_patient_info_brief;
DELIMITER //
CREATE PROCEDURE get_patient_info_brief(IN _id int)
BEGIN
SELECT age, height, weight, sessions, remaining_sessions, `description` FROM patient_info WHERE `id` = _id;
END //
DELIMITER ;
like this:
const auto q1 = QString("CALL get_patient_info_brief(?);");
const auto q2 = QStringLiteral("SELECT age, height, weight, sessions, remaining_sessions, `description` FROM patient_info WHERE `id` = ?;");
auto db = QSqlDatabase::addDatabase("QMYSQL");
db.setDatabaseName("mydb");
db.setUserName("root");
db.setPassword("pswd");
if (db.open()) {
QSqlQuery q(db);
q.prepare(q2);
q.addBindValue(QVariant(1));
if (q.exec()) {
qDebug() << "query executed";
if (q.size()) {
while (q.next()) {
qDebug() << q.record();
}
}
}
}
if I use the q2 the result will be returned back but it's not true with q1
Docs would say:
MySQL 5 introduces stored procedure support at the SQL level, but no API to control IN, OUT, and INOUT parameters. Therefore, parameters have to be set and read using SQL commands instead of QSqlQuery::bindValue().
How can we get manage to do the job with q1 one?
I'm using Qt5.8
+ MySQL 8.0.17
+ MySQL Connector C 6.1