The EGL delete statement removes either a record from a file or a row from a database.
An example is as follows:
if (userRequest = "D") try get myRecord forUpdate; onException myErrorHandler(12); // exits the program end try delete myRecord; onException myErrorHandler(16); end end
The behavior of the delete statement depends on the record type. For details on SQL processing, see SQL record.
If you want to delete an indexed or relative record, do as follows:
After you issue the get statement, the effect of the next I/O operation on the same file is as follows:
For details on the forUpdate option, see get.
In the case of SQL processing, you must use the forUpdate option on an EGL get or open statement to retrieve a row for subsequent deletion:
In either case, the EGL delete statement is represented in the generated code by an SQL DELETE statement that references the current row in a cursor. You cannot modify that SQL statement, which is formatted as follows:
DELETE FROM tableName WHERE CURRENT OF cursor
If you wish to write your own SQL DELETE statement, use the EGL execute statement.
You cannot use a single EGL delete statement to remove rows from multiple SQL tables.
Related concepts
Record types and properties
resultSetID
Run unit
SQL support
Related tasks
Syntax diagram
Related reference
add
close
EGL statements
Exception handling
execute
get
get next
get previous
I/O error values
prepare
open
replace
SQL item properties
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.