Updating a row in mysql
Suppose for each customer, you want to add a row number, and the row number is reset whenever the customer number changes.
The DECLARE statement declares a cursor and associates it with a SELECT statement that retrieves the rows to be traversed by the cursor.
Only the partitions (or subpartitions) listed are checked for matches, and a row that is not in any of these partitions or subpartitions is not updated, whether it satisfies the clause, are flagged as unsafe for statement-based replication.
(This is because the order in which the rows are updated determines which rows are ignored.) With this change, such statements produce a warning in the log when using statement-based mode and are logged using the row-based format when using mode.
While we won't be looking at the use of multiple cursors within the same stored proc, it is entirely possible to have multiple cursors in the same code block, but each cursor must have a unique name. HANDLER statement specifies a handler that deals with one or more conditions.
If one of these conditions occurs, the specified statement executes.