Complete the code to declare a cursor named 'cur' for selecting all rows from the 'employees' table.
DECLARE [1] CURSOR FOR SELECT * FROM employees;The cursor name is declared right after the DECLARE keyword. Here, 'cur' is the cursor name.
Complete the code to open the cursor named 'cur'.
OPEN [1];To start fetching rows, you must open the cursor by its declared name, here 'cur'.
Fix the error in the FETCH statement to retrieve data into the variable 'emp_name'.
FETCH [1] INTO emp_name;The FETCH statement must use the exact cursor name declared and opened, here 'cur'.
Fill both blanks to declare a handler for NOT FOUND condition and close the cursor named 'cur'.
DECLARE CONTINUE HANDLER FOR [1] SET done = TRUE; CLOSE [2];
The handler must catch the 'NOT FOUND' condition, and the cursor to close is 'cur'.
Fill all three blanks to fetch rows from cursor 'cur', check for done, and leave the loop if done.
FETCH [1] INTO emp_name; IF [2] THEN LEAVE [3]; END IF;
FETCH uses cursor 'cur', the done flag is checked, and the loop labeled 'loop_label' is exited.