DL/I の delete に関する考慮事項

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

構文

DL/I の delete の構文図に関する考慮事項
DLISegmentVariable
削除するセグメントに対応する DLISegment 変数の名前。
usingPCB pcbName
PSB レコードで定義されている PCB の名前を指定して、デフォルトの PCB を置換するオプション。
with #dli{ dliStatement }
明示的 DL/I DLET 呼び出しを行うオプション。#dli ディレクティブを参照してください。 #dli と左中括弧の間にスペースは入れません。

以下の例は、顧客データベースからオーダーを削除します。
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

フィードバック