BEGIN...END

Use this combination of MySQL statements to start and end the steps that are part of a stored procedure or trigger.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

BEGIN...END

Explanation

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 semi-colon. However, semi-colons must be used within CREATE PROCEDURE and CREATE TRIGGER statements to separate the internal statements that form the procedure or trigger. In order 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 semi-colon again after entering END. For an example of these statements, see the examples for CREATE PROCEDURE and CREATE TRIGGER.