1BEGIN
2 DECLARE cur_employee CURSOR FOR
3 SELECT Surname
4 FROM Employees;
5 DECLARE name CHAR(40);
6 OPEN cur_employee;
7 lp: LOOP
8 FETCH NEXT cur_employee INTO name;
9 IF SQLCODE <> 0 THEN LEAVE lp END IF;
10 ...
11 END LOOP;
12 CLOSE cur_employee;
13END