DL/I データベース・サンプル

この資料では、一貫性のある経験を提供し、各サンプルを他のサンプルでビルドできるように、 可能な限り同じこの DL/I データベース・サンプルを使用しています。 この顧客データベースでは、ルート・レベルに基本の顧客情報があります。それぞれの顧客ごとに、 クレジット状況、購入履歴、および個々のロケーションのためのセグメントがあります。 各ロケーションにオーダー・セグメントがあり、各オーダーに行項目セグメントがあります。
顧客データベースの図
EGL は、ご使用のプログラムのこれらのセグメントそれぞれを、DLISegment 型のレコードとして表します。 以下のコード例は、このデータベースの構造を EGL でどのように宣言できるかを示しています。 折にふれて、DL/I バージョンのセグメント名およびフィールド名 (最大 8 文字) を使用した DL/I 呼び出しの例も示していきます。 これらの DL/I 名もこのサンプルで示します。
package customer;

 //DL/I DB のセグメントを突き合わせるためのレコードを定義する
Record CustomerRecordPart type DLISegment
{ segmentName="STSCCST", keyItem="customerNo" }
	10 customerNo char(6)      { dliFieldName = "STQCCNO" };  //key field
	10 customerName char(25)   { dliFieldName = "STUCCNM" };
	10 customerAddr1 char(25)  { dliFieldName = "STQCCA1" };
	10 customerAddr2 char(25)  { dliFieldName = "STQCCA2" };
	10 customerAddr3 char(25)  { dliFieldName = "STQCCA3" };
end

Record LocationRecordPart type DLISegment
{ segmentName="STSCLOC", keyItem="locationNo" }
	10 locationNo char(6)      { dliFieldName = "STQCLNO" };  //key field
	10 locationName char(25)   { dliFieldName = "STFCLNM" };
	10 locationAddr1 char(25)  { dliFieldName = "STFCLA1" };
	10 locationAddr2 char(25)  { dliFieldName = "STFCLA2" };
	10 locationAddr3 char(25)  { dliFieldName = "STFCLA3" };
end

Record OrderRecordPart type DLISegment
{ segmentName="STPCORD", keyItem="orderDateNo" }
	10 orderDateNo char(12)       { dliFieldName = "STQCODN" };  //key field
	10 orderReference char(25)    { dliFieldName = "STFCORF" };
	10 orderItemCount num(6)      { dliFieldName = "STFCOIC" };
	10 orderAmount decimal(12,2)  { dliFieldName = "STFCOAM" };
end

Record ItemRecordPart type DLISegment
{ segmentName="STLCITM", keyItem="itemKey" }
	10 itemKey char(8);            //key field
		15 itemInventoryNo char(6)   { dliFieldName = "STKCIIN" };
		15 itemLineNo smallint       { dliFieldName = "STQCILI" };
	10 itemQtyOrdered num(6)       { dliFieldName = "STFCIQO" };
	10 itemQtyShipped num(6)       { dliFieldName = "STFCIQS" };
	10 itemQtyBackOrdered num(6)   { dliFieldName = "STFCIQB" };
	10 itemAmount decimal(12,2)    { dliFieldName = "STFCIAM" };
	10 itemNumber char(6)          { dliFieldName = "STQIINO" };
	10 itemDescription char(25)    { dliFieldName = "STFIIDS" };
	10 itemQtyOnHand num(6)        { dliFieldName = "STFIIQH" };
	10 itemQtyOnOrder num(6)       { dliFieldName = "STFIIQH" };
	10 itemQtyReserved num(6)      { dliFieldName = "STFIIQR" };
	10 itemUnitPrice char(6)       { dliFieldName = "STFIIPR" };
	10 itemUnitOfIssue char(1)     { dliFieldName = "STFIIUN" };
end

Record CreditRecordPart type DLISegment
{ segmentName="STSCSTA" }
	10 creditLimit char(12)      { dliFieldName = "STFCSCL" };
	10 creditBalance char(12)    { dliFieldName = "STFCSBL" };
end

Record HistoryRecordPart type DLISegment
{ segmentName="STSCHIS", lengthItem="historySegmentLength", keyItem="historyDateNo" }
	10 historySegmentLength smallint { dliFieldName = "STGCSL" };
	10 historyDateNo char(12)        { dliFieldName = "STQCHDN" };
	10 historyReference char(25)     { dliFieldName = "STFCHRF" };
	10 historyItemCount smallint     { dliFieldName = "STFCHIC" };
	10 historyAmount decimal(12,2)   { dliFieldName = "STQCHAM" };
	10 historyStatus char(77)        { dliFieldName = "STQCLOS" };
end

//PSB のDBレイアウト全体を宣言する
Record CustomerPSBRecordPart type PSBRecord { defaultPSBName="STBICLG" }
	// IMS の CBLTDLI を必要とする 3 つの PCB
	iopcb IO_PCBRecord { @PCB { pcbType = TP } };
	elaalt ALT_PCBRecord { @PCB { pcbType = TP } };
	elaexp ALT_PCBRecord { @PCB { pcbType = TP } };
	
	// database PCB
	customerPCB DB_PCBRecord { @PCB {
		pcbType = DB,
		pcbName = "STDCDBL",
		hierarchy = [
			@Relationship { segmentRecord = "CustomerRecordPart" },
			@Relationship { 
				segmentRecord = "LocationRecordPart", parentRecord = "CustomerRecordPart" },
			@Relationship { 
				segmentRecord = "OrderRecordPart", parentRecord = "LocationRecordPart" },
			@Relationship { 
				segmentRecord = "ItemRecordPart", parentRecord = "OrderRecordPart" },
			@Relationship { 
				segmentRecord = "CreditRecordPart", parentRecord = "CustomerRecordPart" },
			@Relationship { 
				segmentRecord = "HistoryRecordPart", parentRecord = "CustomerRecordPart" }]}};
end

プログラム PrintCatalog タイプ basicProgram {
	@DLI{ 		
		psb = "myPSB", 		
		callInterface = CBLTDLI, 		
		// IO と ALT PCB のためにスペースを残す
		pcbParms = ["", "", "", "customerPCB"] 	} }

	//レコードのインスタンスを作成する
	myCustomer  CustomerRecordPart;
	myLocation  LocationRecordPart;
	myOrder     OrderRecordPart;
	myItem      ItemRecordPart;
	myCrStatus  CreditRecordPart
	myHistory   HistoryRecordPart

	myPSB       CustomerPSBRecordPart; 

	function main()
	...
	end
end

関連概念
DL/I データベースの基本概念
DL/I データベース・サポート
レコード・タイプとプロパティー
関連参照
@DLI

フィードバック
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.