I have formed the following QString statement to work as a stored procedure to query a DB:
DROP PROCEDURE IF EXISTS mprocedure;
CREATE PROCEDURE mprocedure()
BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN ROLLBACK;
RESIGNAL;
SHOW ERRORS;
END;
START TRANSACTION;
SELECT primaryKey FROM m_schema.`persons_data` where `Name En` = 'jhone' and `date` = '2019-03-09' and `person type` = '3' and `persons_data`.`ID` in (SELECT foreignKey FROM m_schema.`employees` where ` m_date` = '2019-03-09')
commit;
END;
DROP PROCEDURE IF EXISTS mprocedure;
CREATE PROCEDURE mprocedure()
BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN ROLLBACK;
RESIGNAL;
SHOW ERRORS;
END;
START TRANSACTION;
SELECT primaryKey FROM m_schema.`persons_data` where `Name En` = 'jhone' and `date` = '2019-03-09' and `person type` = '3' and `persons_data`.`ID` in (SELECT foreignKey FROM m_schema.`employees` where ` m_date` = '2019-03-09')
commit;
END;
To copy to clipboard, switch view to plain text mode
When I try to call the procedure by :
the following error occurred:
QSqlError("1305", "QMYSQL: Unable to execute query", "PROCEDURE m_schema.mprocedure does not exist")
And if i try to directly execute the same query without using the stored procedure, it executes correctly,
QSqlQuery::exec(SELECT primaryKey FROM m_schema.`persons_data` where `Name En`
= 'jhone' and `date`
= '2019-03-09' and `person type`
= '3' and `persons_data`.`ID` in
(SELECT foreignKey FROM m_schema.`employees` where ` m_date`
= '2019-03-09'))
QSqlQuery::exec(SELECT primaryKey FROM m_schema.`persons_data` where `Name En` = 'jhone' and `date` = '2019-03-09' and `person type` = '3' and `persons_data`.`ID` in (SELECT foreignKey FROM m_schema.`employees` where ` m_date` = '2019-03-09'))
To copy to clipboard, switch view to plain text mode
what is the problem with the first method?
Bookmarks