I am trying to create a stored proecure in MySQL from Qt (since i want to distribute my application)
But exec() will not create a stored procedure. I tried changing the delimiter and everything else that I could think of.
created tables and inserts the date but it does not create procedures and views.
Here is the code.
create_tables_sql =
"DROP PROCEDURE IF EXISTS `test`.`GetStockTotal`;"
"CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.`GetStockTotal`(IN curstockid INT(11), OUT stocktotal DECIMAL(15,2))"
"BEGIN"
"DECLARE stocktotal FLOAT DEFAULT 0;"
"SELECT opbalance INTO stocktotal from ledgers where curid = curstockid;"
"END;";
me.exec();
QString create_tables_sql;
create_tables_sql =
"DROP PROCEDURE IF EXISTS `test`.`GetStockTotal`;"
"CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.`GetStockTotal`(IN curstockid INT(11), OUT stocktotal DECIMAL(15,2))"
"BEGIN"
"DECLARE stocktotal FLOAT DEFAULT 0;"
"SELECT opbalance INTO stocktotal from ledgers where curid = curstockid;"
"END;";
QSqlQuery me;
me.exec();
To copy to clipboard, switch view to plain text mode
Are there any work around other than doing it directly from MySQL.
Bookmarks