Example 1 (Fetch All Rows)
This script iterates through a table and fetches all the rows. It assumes a Northwind access database named access and gathers all the categories in the table Categories.
PROCEDURE fetchExample1 (OUT category CHAR)
BEGIN
DECLARE temp CHAR;
DECLARE f CURSOR FOR SELECT Categories.CategoryName
FROM /shared/access/Categories Categories;
SET category = '';
OPEN f;
FETCH f INTO temp;
-- Must call FETCH first, otherwise FOUND is false.
WHILELOOP:
WHILE f.FOUND
DO
BEGIN
SET category = CAST(CONCAT(CONCAT(category, ' '), temp)AS CHAR(255));
FETCH f INTO temp;
END;
END WHILE;
CLOSE f;
END