Updating record through cursor
That allows us to perform operations on every record on a one-by-one basis.The DECLARE statement declares a cursor and associates it with a SELECT statement that retrieves the rows to be traversed by the cursor.
A cursor is a special kind of loop for traversing through an SQL resultset one row at a time.
Cases have been reported where sort order interferes with expectations, without involving a subquery.
It happens because, in the execution layers, instead of establishing a stable “” and then executing the data changes to each set member, DML statements use implicit cursors for performing the operations on whatever row currently meets the conditions, without knowledge of whether that row formerly failed the condition or was updated already.
At that point, a No Data condition fires with SQLSTATE value '02000'.
Some people check for this string literal to detect a NOT FOUND condition, but I personally feel that the NOT FOUND constant is clearer.
The string literal is preceded by the character set name, prefixed with an underscore character: ”, will continuously update rows, over and over, and give the impression that the server has hung.