a cursor can use variables, but the query itself cannot be a variable, and cannot be dynamically composed. The SELECT statement cannot have an INTO clause. Cursors must be declared before HANDLERs, but after local variables and CONDITIONs. Parameters ---------- MariaDB starting with 10.3.0 ---------------------------- From MariaDB 10.3.0, cursors can have parameters. This is a non-standard SQL extension. Cursor parameters can appear in any part of the DECLARE CURSOR select_statement where a stored procedure variable is allowed (select list, WHERE, HAVING, LIMIT etc). IN -- MariaDB starting with 10.8.0 ---------------------------- From MariaDB 10.8.0 preview release, the IN qualifier is supported in the cursor_format_parameter part of the syntax. See Cursor Overview for an example. URL: https://mariadb.com/kb/en/declare-cursor/https://mariadb.com/kb/en/declare-cursor/