Programmatic & Compound Statements

Compound statements in MariaDB can be used both inside and outside (starting from MariaDB 10.1.1) of stored programs.

Title Description
Using Compound Statements Outside of Stored Programs Compound statements are not just for stored programs.
BEGIN END How to write compound statements.
CASE Statement Conditional construct with multiple choices.
DECLARE CONDITION For declaring a named error condition (SQLSTATE or error code).
DECLARE HANDLER Construct to declare how errors are handled.
DECLARE Variable Declare local variables within stored programs.
FOR FOR loops allow code to be executed a fixed number of times.
GOTO Jump to the given label.
IF A basic conditional construct statement.
ITERATE Used to repeat the execution of the current loop.
Labels Identifiers used to identify a BEGIN ... END construct.
LEAVE Used to exit a code block.
LOOP Used to loop within a code block without a condition.
REPEAT LOOP Used to repeat statements until a search condition is true.
RESIGNAL Used to send a SIGNAL again for the previous error.
RETURN Statement to terminate execution of a stored function and return a value.
SELECT INTO SQL statement for inserting values into variables.
SET Variable Used to insert a value into a variable with a code block.
SIGNAL May be used to produce a custom error message.
WHILE Used to repeat a block of SQL statements while a search condition is true.
Cursors Structure for traversing and processing results, sequentially.
Diagnostics Error conditions and statement information.
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.

© 2021 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/programmatic-compound-statements/