此上下文中的 INTO 子句的规范将覆盖相关 open 语句中标识的任何 INTO 子句。
在大多数情况下,EGL 运行时会发出隐式的 close 语句,它会在 forEach 语句的最后一次迭代后发生。这一隐式语句会修改 SQL 系统变量,因此您可能想要将与 SQL 有关的系统变量的值保存在 forEach 语句的主体中。
如果 forEach 语句因为 noRecordFound 之外的错误而终止,所以 EGL 运行时不会发出隐式 close 语句。
VGVar.handleHardIOErrors = 1; try open selectEmp with #sql{ select empnum, empname from employee where empnum >= :empnum for update of empname } into empnum, empname; onException myErrorHandler(6); // exits program end try forEach (from selectEmp) empname = empname + " " + "III"; try execute #sql{ update employee set empname = :empname where current of selectEmp }; onException myErrorHandler(10); // exits program end end // end forEach; cursor is closed automatically // when the last row in the result set is read onException // the exception block related to forEach is not run if the condition // is "sqlcode = 100", so avoid the test "if (sqlcode != 100)" myErrorHandler(8); // exits program end sysLib.commit();
相关概念
resultSetID
SQL 支持
相关任务
EGL 语句和命令的语法图