BEGIN...END
BEGIN...END
Use this combination of statements to start and end the
steps that are part of a stored procedure or trigger. In essence, BEGIN marks the
beginning of a compound SQL statement and END marks
the end of it. Multiple SQL statements can be included between
them.
Traditionally, as you know from using the mysql
client, each SQL statement must end with a semicolon. However,
semicolons must be used within CREATE PROCEDURE and CREATE TRIGGER statements to separate the internal statements
that form the procedure or trigger. So as not to confuse the parser in
the client and server, include a DELIMITER command to change the
default delimiter to another character before entering
BEGIN, and then to set it back to a semicolon again
after entering END. For examples of these
statements, see the CREATE PROCEDURE and CREATE TRIGGER statements later in this chapter.