DL/I のコンテキストにおいて、delete ステートメントは階層データベースからセグメントを削除します。
delete ステートメントは DL/I DLET ステートメントを生成します。 DL/I では、セグメントを削除する前に、そのセグメントを取得し、保持しておく必要があります。delete ステートメントを使用する前に、EGL get ステートメントを forUpdate オプションと組み合わせて使用します。
forUpdate オプションの使用例を以下に示します。
if (userRequest == "D")
try
get myRecord forUpdate;
onException(dex DLIException)
myErrorHandler(dex); // プログラムを終了する
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;
//セグメント検索パラメーターをビルドする
myCustomer.customerNo = "005001";
myLocation.locationNo = "000022";
myOrder.orderDateNo = "20050730A003";
//要求されたオーダー・レコードを保持する
try
get myOrder forUpdate;
onException(dex DLIException)
myErrorHandler(dex);
end
//オーダーを削除する
try
delete myOrder;
onException(dex DLIException)
myErrorHandler(dex);
end
get...forUpdate ステートメントは、顧客、ロケーション、およびオーダーの修飾 SSA を生成します。GHU STSCCST (STQCCNO = :myCustomer.customerNo)
STSCLOC (STQCLNO = :myLocation.locationNo)
STPCORD (STQCODN = :myOrder.orderDateNo)
その後、delete ステートメントは、単一行のコードを生成します。DLET STPCORD