Frequently Asked Questions

Help Center Search

Are stored procedures supported in MySQL?

Print this Article
Comment on this Article
Last Updated: November 12, 2008 9:28 AM

Stored procedures are supported in MySQL 5.0. A stored procedure is a set of SQL statements that can be stored in the server. Once this has been done, clients don't need to keep reissuing the individual statements but can refer to the stored procedure instead.

NOTE: This procedure applies only to Dedicated/Virtual Dedicated servers, as it requires executing the command from the MySQL command line. Customers using Shared Hosting will have to execute this procedure using phpMyAdmin, by removing the DELIMITER statements and instead using the "Delimiter" field provided in the phpMyAdmin query window.

An example of an allowed stored procedure:

DELIMITER $$
DROP PROCEDURE IF EXISTS `spGetSouls`$$

CREATE PROCEDURE `spGetSouls`()
DETERMINISTIC
BEGIN
SELECT * FROM soul;
END$$
DELIMITER ;

CALL spGetSouls();

NOTE: Be sure that your stored procedures are labeled as DETERMINISTIC

For more information on stored procedures, see the MySQL Web site and Stored Procedures Frequently Asked Questions.