MySQL Compound-Statement Syntax
1137
To deallocate a prepared statement produced with
PREPARE
, use a
DEALLOCATE PREPARE
statement
that refers to the prepared statement name. Attempting to execute a prepared statement after
deallocating it results in an error.
For examples, see
Section 13.5, “SQL Syntax for Prepared Statements”
.
13.6. MySQL Compound-Statement Syntax
This section describes the syntax for the
BEGIN ... END
compound statement and other statements
that can be used in the body of stored programs: Stored procedures and functions and triggers.
These objects are defined in terms of SQL code that is stored on the server for later invocation (see
Chapter 18, Stored Programs and Views
).
A compound statement is a block that can contain other blocks; declarations for variables, condition
handlers, and cursors; and flow control constructs such as loops and conditional tests.
13.6.1.
BEGIN ... END
Compound-Statement 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, and triggers). 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
Section 18.1, “Defining Stored Programs”
.
A
BEGIN ... END
block can be labeled. See
Section 13.6.2, “Statement Label Syntax”
.
The optional
[NOT] ATOMIC
clause is not supported. This means that no transactional savepoint is
set at the start of the instruction block and the
BEGIN
clause used in this context has no effect on the
current transaction.
Note
Within all stored programs, the parser treats
BEGIN [WORK]
as the beginning
of a
BEGIN ... END
block. To begin a transaction in this context, use
START
TRANSACTION
instead.
13.6.2. Statement Label Syntax
[
begin_label
:] BEGIN
[
statement_list
]
END [
end_label
]
[
begin_label
:] LOOP
statement_list
END LOOP [
end_label
]
[
begin_label
:] REPEAT
statement_list
UNTIL
search_condition
END REPEAT [
end_label
]
[
begin_label
:] WHILE
search_condition
DO
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...