This tutorial explains how to use the CLOSE statement to close a cursor in MySQL with syntax and examples.
The final step in MySQL is to close the cursor once you have finished using it.
The syntax to close a cursor in MySQL is:
The name of the cursor that you wish to close.
For example, you could close a cursor called c1 in MySQL with the following command:
Below is a function that demonstrates how to use the CLOSE statement:
CREATE FUNCTION FindSiteID ( name_in VARCHAR(50) )
DECLARE done INT DEFAULT FALSE;
DECLARE siteID INT DEFAULT 0;
DECLARE c1 CURSOR FOR
WHERE site_name = name_in;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
FETCH c1 INTO siteID;
Copyright 2020. All Rights Reserved