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.

Qt Code:
  1. QString create_tables_sql;
  2.  
  3. create_tables_sql =
  4. "DROP PROCEDURE IF EXISTS `test`.`GetStockTotal`;"
  5. "CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.`GetStockTotal`(IN curstockid INT(11), OUT stocktotal DECIMAL(15,2))"
  6. "BEGIN"
  7. "DECLARE stocktotal FLOAT DEFAULT 0;"
  8. "SELECT opbalance INTO stocktotal from ledgers where curid = curstockid;"
  9. "END;";
  10.  
  11. me.exec();
To copy to clipboard, switch view to plain text mode 

Are there any work around other than doing it directly from MySQL.