NOTE: I have already referenced the question on Call a stored procedure for each row returned by a query in MySQL and have modeled my code after it.
I had created a stored procedure called NearbyCities and it works when I call it by inputting one location. Now, I have 660 locations and rather than calling it 660 times manually, I discovered that I could create another procedure using cursors to do this job for me. So by referencing various resources, I had came out with the following code:
DELIMITER //
CREATE PROCEDURE LocationCursor()
BEGIN
DECLARE `Finished` INT DEFAULT FALSE;
DECLARE `ID` VARCHAR(5);
DECLARE `Location` VARCHAR(255);
DECLARE `Street` VARCHAR(255);
DECLARE `City` VARCHAR(255);
DECLARE `State` VARCHAR(255);
DECLARE `Zip Code` VARCHAR(255);
DECLARE `Latitude` VARCHAR(255);
DECLARE `Longitude` VARCHAR(255);
DECLARE `LocCursor` CURSOR
FOR SELECT `ID`
,`Location`
,`Street`
,`City`
,`State`
,`Zip Code`
,`Latitude`
,`Longitude`
FROM `LocationDirectory`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET `Finished` = TRUE;
OPEN `LocCursor`;
ReadLoop: LOOP
FETCH NEXT FROM `LocCursor` INTO `ID`
,`Location`
,`Street`
,`City`
,`State`
,`Zip Code`
,`Latitude`
,`Longitude`;
IF `Finished` = TRUE
THEN LEAVE ReadLoop;
END IF;
CALL NearbyCities(`ID`);
END LOOP ReadLoop;
CLOSE `LocCursor`;
END //
DELIMITER ;
CALL LocationCursor();
Now, the code compiles, but the results table shows nothing when I call it. What am I missing?