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.

Be careful that your numArgs is correct. If it isn't, you may get a mysql.exceptions.MYX with a very unclear error message.

prepareProcedure

Parameters

name string

The name of the stored procedure.

numArgs int

The number of arguments the stored procedure takes.

Throws

mysql.exceptions.MYX if the server has a problem.

Examples

t
{
	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");
	cn.exec(preparedInsert2);

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

Meta