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 DL/I processing, see DLISegment record. For SQL processing, see SQL record.
The delete statement generates a DL/I DLET statement. In DL/I, you must get and hold a segment before deleting it. The EGL keywords get...forUpdate, get next...forUpdate, and get next inParent...forUpdate will all hold the requested segment for deletion.
//create instances of the records myCustomer CustomerRecord; myLocation LocationRecord; myOrder OrderRecord; //build a segment search argument myCustomer.customerNo = "005001"; myLocation.locationNo = "000022"; myOrder.orderDateNo = "20050730A003"; //hold the requested order record try get myOrder forUpdate; onException myErrorHandler(2); end //delete the order try delete myOrder; onException myErrorHandler(7); endThe get...forUpdate statement generates qualified SSAs for customer, location, and order:
GHU STSCCST (STQCCNO = :myCust.customerNo) STSCLOC (STQCLNO = :myLocation.locationNo) STPCORD (STQCODN = :myOrder.orderDateNo)The delete statement then simply generates the following:
DLET STPCORD
For details on the forUpdate option, see get.
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
DL/I database support
Record types and properties
resultSetID
Run unit
SQL support
Related tasks
Syntax diagram for EGL statements and commands
Related reference
#dli directive
add
CICS-related considerations
close
EGL statements
Exception handling
execute
get
get next
get next inParent
get previous
I/O error values
prepare
open
replace
set
SQL item properties
terminalID