prepareProcedure

Convenience function to create a prepared statement which calls a stored procedure.

OUT parameters are currently not supported. It should generally be possible with MySQL to present them as a result set.

prepareProcedure

Parameters

name string

The name of the stored procedure.

numArgs int

The number of arguments the stored procedure takes.

Throws

MySQLException if there are pending result set items, or if the server has a problem.

Examples

t
{
	debug(MYSQL_INTEGRATION_TESTS)
	{
		import mysql.test.common;
		import mysql.test.integration;
		mixin(scopedCn);
		initBaseTestTables(cn);

		exec(cn, `DROP PROCEDURE IF EXISTS insert2`);
		exec(cn, `
			CREATE PROCEDURE insert2 (IN p1 INT, IN p2 CHAR(50))
			BEGIN
				INSERT INTO basetest (intcol, stringcol) VALUES(p1, p2);
			END
		`);

		auto preparedInsert2 = prepareProcedure(cn, "insert2", 2);
		preparedInsert2.setArgs(2001, "inserted string 1");
		preparedInsert2.exec();

		ResultSet rs = querySet(cn, "SELECT stringcol FROM basetest WHERE intcol=2001");
		assert(rs.length == 1);
		assert(rs[0][0] == "inserted string 1");

Meta