Step-1:

In this stored procedure, we declare a cursor variable cur that retrieves the names and marks columns from the marks table.

Step-2:

We also declare variables input_name, input_marks, to store the values fetched from the cursor

Step-3:

Inside the loop, we fetch the values into the variables input_name and input_marks using the FETCH statement. If there are no more rows to fetch (done is TRUE), we leave the loop.

Change the select cmd:

The CONTINUE HANDLER FOR NOT FOUND is used to set the done variable to TRUE when there are no more rows to fetch from the cursor.