The following example illustrates the use of FOR loop aliases in the conditional expressions of a searched CASE statement:
CREATE PROCEDURE spSample() Label1:BEGIN FOR RowPointer AS c_employee CURSOR FOR SELECT DeptNo AS c_DeptNo, employeeid AS c_empid FROM Employee DO CASE WHEN RowPointer.c_DeptNo > 10 THEN INSERT INTO Dept VALUES (RowPointer.c_DeptNo, RowPointer.c_empid) ; WHEN RowPointer.c_DeptNo <= 10 THEN UPDATE Employee SET DeptNo = RowPointer.c_DeptNo + 10 ; INSERT INTO Dept VALUES (RowPointer.c_DeptNo, RowPointer.c_empid) END CASE; END FOR; END Label1;