When you use the delete statement in the context of SQL, the statement removes a row from a database. You must have previously retrieved the record using a get or open statement with the forUpdate option.
DELETE FROM tableName
WHERE CURRENT OF cursor
You do not have the option of rewriting this statement
using the #sql directive. Use the EGL execute statement
to write a custom SQL DELETE statement.You cannot use a single EGL delete statement to remove rows from multiple SQL tables.

The following example shows the delete statement for SQL:
try
get dept forUpdate;
dept.description = "Test Engineers";
delete dept;
commit();
onException(sqlEx SQLException)
sqlFailure();
end
The following example shows the delete statement for Multiple Row:
employees Employee[0]{rowsetsize=10};
Open resultset1 forUpdate with #sql{
select eID, uName, PASSWORD, fName, lName, office, sex, EMail
from EMPLOYEETEST
} for employees;
Get Next employees;
Delete employees[2]; //this deletes the second row in the row set using
//“WHERE CURRENT OF CS1”
i int = 2;
Delete employees[i]; //the index could be a variable
Delete employees; //this deletes the whole row set from current cursor
| Platform | Issue |
|---|---|
| COBOL generation | For best performance in COBOL, always include the from resultSet clause in the delete statement. |
| SQL Server | Multiple Row delete last and get last cannot be used together. The result set will be closed when both statements are executed once. |
| DB2® for i5/OS™ | Journaling must be enabled or add transation isolation=none to the connection string. |