Programmatic & Compound Statements
Explore programmatic compound statements in MariaDB Server. This section covers BEGIN...END blocks, loops, and conditional logic for writing complex stored routines and event definitions.
Group multiple SQL statements into a logical block. This construct defines a compound statement, creating a new scope for variables and exception handling.
Complete reference for CASE Statement in MariaDB. Complete syntax guide with all options, clauses, and practical examples with comprehensive examples and.
Define named error conditions. This statement associates a name with a specific SQLSTATE or MariaDB error code for easier handling in stored programs.
Specify actions for error conditions. This statement defines handler routines (CONTINUE or EXIT) to manage exceptions or warnings within a block.
Define data types for Oracle compatibility. This statement allows declaring PL/SQL-style record types and associative arrays, and REF CURSOR types within stored procedures.
Initialize local variables within a stored program. This statement defines variables with a specific data type and optional default value.
Loop through a range or cursor result set. This control flow statement repeatedly executes a block of code for each item in a specified range or query.
Jump to a labeled point in the code. This Oracle-compatible statement transfers execution control to a specific label within the stored program.
Execute code based on conditions. This control flow statement runs different blocks of SQL statements depending on whether a specified condition is true.
Restart the current loop. This statement jumps back to the beginning of a LOOP, REPEAT, or WHILE block, skipping any remaining statements in the current iteration.
Identify blocks and loops for flow control. Labels provide names for BEGIN...END blocks or loops, allowing them to be targeted by LEAVE, ITERATE, or GOTO statements.
Exit a labeled block or loop immediately. This statement terminates the execution of the current loop or compound statement and continues after the block.
Create a simple loop construct. This statement repeatedly executes a block of code until explicitly terminated by a LEAVE statement.
Execute a block until a condition is met. This loop construct runs at least once and continues repeating as long as the UNTIL condition remains false.
Propagate error conditions. This statement allows a handler to pass an error condition back to the caller or modify the error information before passing it on.
Exit a stored function and return a value. This statement terminates function execution and sends the specified result back to the caller.
Assign query results to variables. This statement retrieves column values from a single row and stores them in local variables or user-defined variables.
Raise a custom error condition. This statement allows stored programs to generate specific error messages and SQLSTATEs to handle application logic exceptions.
Execute a block while a condition is true. This loop construct checks a condition before each iteration and repeats the block as long as the condition holds.
Use compound statements such as IF and BEGIN...END outside of stored programs, with the delimiter set appropriately.
Learn about cursors in MariaDB Server's programmatic compound statements. This section details how to iterate over result sets row-by-row within stored procedures and functions.
Learn about diagnostics in programmatic compound statements. This section covers error handling and information retrieval within stored procedures and functions for effective debugging.
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

