CURRENT is a reserved Standard SQL keyword that refers to the “row in focus” of an executing statement. It shows up in two main contexts:1. Positioned UPDATE or DELETE • Syntax: WHERE CURRENT OF cursor_name • Meaning: Modify or remove the single row most recently fetched by the named cursor. • Requirements: The cursor must be declared FOR UPDATE/DELETE, opened, and positioned on a row. If the cursor is closed or not positioned, the statement raises SQLSTATE 24000. • Benefits: Eliminates the need to repeat a full primary-key predicate, reducing race conditions while looping through result sets.2. Window-frame specifications • Example: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW • Meaning: Include the current row in the frame boundary so analytic functions (SUM, AVG, etc.) are calculated up to that row.The keyword cannot be selected or assigned directly and has no parameters by itself. It always appears as part of a larger clause (CURRENT OF, CURRENT ROW).
cursor_name
(identifier) - Name of an open, updatable cursor currently positioned on a rowSQL-92
Use it when looping through a cursor and you need to update or delete the exact row you just fetched, without rewriting a WHERE clause based on primary keys.
No. MySQL cursors exist only in stored procedures and do not implement positioned UPDATE or DELETE. Use a regular UPDATE with a key predicate instead.
CURRENT ROW is a window-frame boundary that includes the present row in calculations. It uses the same underlying concept – referencing the row currently being processed.
The database raises an invalid cursor state error (SQLSTATE 24000). The cursor must be open and a FETCH must have been executed before WHERE CURRENT OF.