MySQL tutorial: BEGIN END [EN]
top of page
CerebroSQL

MySQL: 

BEGIN END

Syntax:
[begin_label:] BEGIN
[statement_list]
END [end_label]

BEGIN ... END syntax is used for writing compound statements, which can
appear within stored programs (stored procedures and functions,
triggers, and events). A compound statement can contain multiple
statements, enclosed by the BEGIN and END keywords. statement_list
represents a list of one or more statements, each terminated by a
semicolon (;) statement delimiter. The statement_list itself is
optional, so the empty compound statement (BEGIN END) is legal.

BEGIN ... END blocks can be nested.

Use of multiple statements requires that a client is able to send
statement strings containing the ; statement delimiter. In the mysql
command-line client, this is handled with the delimiter command.
Changing the ; end-of-statement delimiter (for example, to //) permit ;
to be used in a program body. For an example, see
https://dev.mysql.com/doc/refman/8.0/en/stored-programs-defining.html.

A BEGIN ... END block can be labeled. See [HELP labels].

URL: https://dev.mysql.com/doc/refman/8.0/en/begin-end.html

Example

bottom of page