In most cases, the EGL runtime issues an implicit SQL CLOSE statement after the last iteration of the loop. Because that implicit statement modifies the SQL system variables, you must save the values of SQL-related system variables in the body of the forEach statement.
The EGL runtime does not perform the SQL CLOSE statement if the forEach statement ends because of an error other than noRecordFound.

Creating an INTO clause in this context overrides any INTO clause from the related open statement.
vgVar.handleHardIOErrors = 1;
try
open myResults for myCustomer
with #sql{
SELECT customer_number, customer_name
FROM Customer
WHERE customer_number >= :myCustomer.customerNumber
FOR UPDATE OF customer_name
}
into myCustomer.customerNumber, myCustomer.customerName;
onException(sqlEx SQLException)
myErrorHandler(6); // exits program
end
try
forEach (from myResults)
// make last name first
reverseName(myCustomer.customerName);
try
execute
#sql{
UPDATE Customer
SET customer_name = :myCustomer.customerName
WHERE CURRENT OF myResults
};
onException(sqlEx SQLException)
myErrorHandler(10); // exits program
end
end
onException(sqlEx SQLException)
myErrorHandler(8); // exits program
end
sysLib.commit();
onException(sqlEx SQLException)
if (sqlcode != 100) // unnecessary test