Categories
MySQL

Creating a Stored Procedure – MySQL 5.0

DELIMITER$$
   CREATE PROCEDURE testing(IN ID INT)
     BEGIN
        SELECT COUNT(*) AS numrows FROM clients.clients_domain;
     END$$
DELIMITER;

The “DELIMITER $$” statement causes MySQL to use two dollar signs ($$) as it’s end-of-line delimiter, instead of a semi-colon (;). This will allow any SQL between the BEGIN and END to have a semi-colon at the end of the line, without causing MySQL to think the query is done. The END statement needs the two dollar signs after it so MySQL knows the query is done and ready to be executed.