I have this working, here is the code I have used:
#include <mysql_connection.h>
#include <driver.h>
#include <exception.h>
#include <resultset.h>
#include <statement.h>
using namespace std;
using namespace sql;
Driver *m_dDBDriver;
Connection *m_cDBConn;
m_dDBDriver = get_driver_instance();
m_cDBConn = m_dDBDriver->connect(url,user,pass);
m_cDBConn->setSchema(schema);
Statement *stmt;
ResultSet *res;
stmt = m_cDBConn->createStatement();
sQSQL = "CALL multiExecute('SELECT 1;SELECT 2;');";
stmt->execute(sQSQL);
do {
res = stmt->getResultSet();
while (res->next()) {
cout << "Value: " << res->getString(1) << "\n";
}
} while (stmt->getMoreResults());
Note that I was looking for this solution to be able to bundle queries, not call stored procedures specifically, the following is a stored procedure that enables this in MySQL:
DROP PROCEDURE IF EXISTS multiExecute;
DELIMITER $$
CREATE PROCEDURE multiExecute(VQuery VARCHAR(1000))
BEGIN
DECLARE VQueryExecuteLen INTEGER;
IF RIGHT(VQuery, 1) != ';' THEN SET VQuery = CONCAT(VQuery, ';'); END IF;
WHILE INSTR(VQuery, ";") > 0 DO
SET VQueryExecuteLen = INSTR(VQuery, ";");
SET @VQueryExecute = LEFT(VQuery, VQueryExecuteLen);
PREPARE stmt FROM @VQueryExecute;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET VQuery = RIGHT(VQuery, CHAR_LENGTH(VQuery) - VQueryExecuteLen);
END WHILE;
END$$
DELIMITER ;
CALL multiExecute('SELECT 1; SELECT 2');
Whether this is quicker or slower than launching each query independently depends on the lag in network infrastructure between your code and the DB, although in my case solutions are comparative in terms of speed when bundling queries.
Post back if you have any issues with implementation.
Regards,
James