replace

DL/I의 컨텍스트에서 replace 문은 변경된 레코드를 계층 구조 데이터베이스에 넣습니다.

replace 문은 DL/I REPL 문을 생성합니다. DL/I에서 세그먼트를 겹쳐쓰려면 우선 세그먼트를 가져와서 보유해야 합니다. EGL 키워드 get...forUpdate, get next...forUpdateget next inParent...forUpdate는 모두 대체를 위해 요청된 세그먼트를 보유합니다.

구문

DL/I replace 문 고려사항의 구문 다이어그램
DLISegmentVariable
대체할 세그먼트에 해당하는 DLISegment 변수의 이름입니다.
usingPCB pcbName
기본 PCB 대신 사용하도록 PSB 레코드에 정의된 PCB의 이름을 지정하는 옵션입니다.
with #dli{ dliStatement }
#dli 지시문에 설명된 대로 명시적 DL/I REPL문을 허용하는 옵션입니다. #dli와 왼쪽 중괄호 사이에 공백을 두지 마십시오.

예제

다음 예제는 고객 데이터베이스에서 주문을 겹쳐씁니다.
// define DLI Segment records using the hostVarQualifier property
Record CustomerRecordPart type DLISegment
{ segmentName="STSCCST", keyItem="customerNo", hostVarQualifier="myCustomer" }
...
endRecord LocationRecordPart type DLISegment
{ segmentName="STSCLOC", keyItem="locationNo", hostVarQualifier="myLocation" }
...
endRecord 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