The most unusual syntax

After nice and clean syntax of C and Java, some features of SQL appear a little quirky. OK, Perl with its pattern matching has infinitely unreadable pieces of valid code, but I didn’t expect anything unusual from a relatively simple language like SQL, in particular its realization within MySQL. The quirky feature is the change of a delimiter, the symbol, which ends statements. Who would have thought one needs to change that symbol?!

# Before defining a stored procedure we change the delimiter, so that MySQL interpreter does not think the statement is over seeing “;” inside the body of a procedure

DELIMITER //
CREATE PROCEDURE MailingListCount (OUT Num INT)
BEGIN
SELECT COUNT(*) INTO Num FROM Customers;
END//
DELIMITER ;
CALL MailingListCount(@a);
SELECT @a;

Leave a Reply

Your email address will not be published. Required fields are marked *