replace

DL/I のコンテキストでは、replace ステートメントによって変更済みレコードが階層データベースに配置されます。

replace ステートメントは、DL/I REPL ステートメントを生成します。 DL/I では、セグメントを上書きする前に、そのセグメントを取得し、保持しておく必要があります。EGL キーワードの get...forUpdateget next...forUpdate、および get next inParent...forUpdate はすべて、 置換のために要求されたセグメントを保持します。

構文

構文図 - DL/I replace ステートメントの考慮事項
DLISegmentVariable
置換するセグメントに対応する DLISegment 変数の名前。
usingPCB pcbName
PSB レコードで定義されている PCB の名前を指定して、デフォルトの PCB の代わりに使用するオプション。
with #dli{ dliStatement }
明示的な DL/I REPL ステートメントを許可するオプション (記述は #dli directive)。#dli と左中括弧の間にスペースは入れません。

次の例では、顧客データベースのオーダーを上書きしています。
//hostVarQualifier プロパティーを使用して DLI セグメント・レコードを定義する
Record CustomerRecordPart type DLISegment
{ segmentName="STSCCST", keyItem="customerNo", hostVarQualifier="myCustomer" }
...
end
Record LocationRecordPart type DLISegment
{ segmentName="STSCLOC", keyItem="locationNo", hostVarQualifier="myLocation" }
...
end
Record OrderRecordPart type DLISegment
{ segmentName="STPCORD", keyItem="orderDateNo", hostVarQualifier="myOrder" }
...
end

	//create variables for the records
	myCustomer CustomerRecordPart;
	myLocation LocationRecordPart;
	myOrder    OrderRecordPart;

	//build a segment search argument
	myCustomer.customerNo = "5001";
	myLocation.locationNo = "22";
	myOrder.orderDateNo = "20050730A003";

	//hold the requested order segment
	try
		get myOrder forUpdate;
		onException(dex DLIException)
			myErrorHandler(dex);
	end
	
	//update the information
	changeOrder(myOrder);

	//rewrite the order
	try
		replace myOrder;
		onException(dex DLIException)
			myErrorHandler(dex);
	end
get...forUpdate ステートメントは、顧客、ロケーション、およびオーダーの修飾 SSA を生成します。
GHU STSCCST (STQCCNO = :myCustomer.customerNo) 
    STSCLOC (STQCLNO = :myLocation.locationNo) 
    STPCORD (STQCODN = :myOrder.orderDateNo)
replace ステートメントは、 続いて次を生成します。
REPL STPCORD

フィードバック