The delete statement generates a DL/I DLET statement. In DL/I, you must get and hold a segment before you can delete it. Use the EGL get statement in combination with the forUpdate option before using the delete statement.
The following example shows the forUpdate option:
if (userRequest == "D")
try
get myRecord forUpdate;
onException(dex DLIException)
myErrorHandler(dex); // exits the program
end
try
delete myRecord;
onException(dex DLIException)
myErrorHandler(dex);
end
end

Record CustomerRecord type DLISegment
{ segmentName="STSCCST", keyItem="customerNo", hostVarQualifier="myCustomer" }
...
end
Record LocationRecord type DLISegment
{ segmentName="STSCLOC", keyItem="locationNo", hostVarQualifier="myLocation" }
...
end
Record OrderRecord type DLISegment
{ segmentName="STPCORD", keyItem="orderDateNo", hostVarQualifier="myOrder" }
...
end
//create variables for the records
myCustomer CustomerRecord;
myLocation LocationRecord;
myOrder OrderRecord;
//build a segment search parameter
myCustomer.customerNo = "005001";
myLocation.locationNo = "000022";
myOrder.orderDateNo = "20050730A003";
//hold the requested order record
try
get myOrder forUpdate;
onException(dex DLIException)
myErrorHandler(dex);
end
//delete the order
try
delete myOrder;
onException(dex DLIException)
myErrorHandler(dex);
end
The get...forUpdate statement
generates qualified SSAs for customer, location, and order:GHU STSCCST (STQCCNO = :myCustomer.customerNo)
STSCLOC (STQCLNO = :myLocation.locationNo)
STPCORD (STQCODN = :myOrder.orderDateNo)
The delete statement
then generates a single line of code:DLET STPCORD