This MariaDB tutorial explains how to set up a handler for the NOT FOUND condition for a cursor in MariaDB with syntax and examples.
If you try to fetch data from a cursor and there are no rows, MariaDB will raise a NO DATA error. You can set up a handler for the NOT FOUND condition so that your stored program does not terminate with an error.
The syntax to set up a handler for the NOT FOUND condition for a cursor in MariaDB is:
The condition to set when the NOT FOUND condition is encountered by the cursor.
Let's look at how to set up a handler for the NOT FOUND condition for a cursor in MariaDB.
First, we need to declare a variable that will be set when the NO DATA error occurs.
Next, we need to declare the cursor.
Finally, we need to declare a handler for the NOT FOUND condition for the cursor.
Below is a function that demonstrates how to put all of these components together to set up a handler for the NOT FOUND condition for a cursor in MariaDB so that your stored program will not terminate with an error.