get myCustomer, myLocation;This statement generates the following DL/I pseudocode:
GU STSCCST*D (STQCCNO = :myCustomer.customerNo) STSCLOC (STQCLNO = :myLocation.locationNo)
get myCustomer, myLocation forUpdate; replace myLocation with #dli{ REPL STSCCST*N STSCLOC };The default DL/I call EGL builds for a delete function that follows a get forUpdate statement with D command codes does not delete each segment retrieved. It deletes only the I/O object segment.
redefCustomer myCustomerRecordPart {redefines=myHistoryRecordPart}; redefLocation myLocationRecordPart {redefines=myHistoryRecordPart}; ... //read next segment, whatever type it is, into history record while (myHistory not EOF) get next myHistory with #dli{ GN }; //so what type was it? case (DLIVar.segmentName) when "STSCCST" // it was a customer myCustomer = redefCustomer; printCustomer(); // myCustomer is global when "STSCLOC" // it was a location myLocation = redefLocation; printLocation(); ... end end
// database PCB customerPCB DB_PCBRecord { @PCB { pcbType = DB, pcbName = "STDCDBL", secondaryIndex = "STFCORF", //use DL/I name hierarchy = [ @Relationship { segmentRecord = "myCustomerRecordPart"}, @Relationship { segmentRecord = "LocationRecord", parentRecord = "myCustomerRecordPart" }, @Relationship { segmentRecord = "OrderRecord", parentRecord = "myLocationRecordPart" }, ...Perform a get operation to locate a customer, as in the following example:
get myCustomer;EGL will generate the following code by default:
GU STSCCST (STFCORF = :myOrder.orderReference)If you wish to be able to choose between accessing customers by orderReference or by customerNo, create a second PCB for your secondary index. In the following example the second PCB is named orderReferencePCB:
// database PCB--access by customer number customerPCB DB_PCBRecord { @PCB { pcbType = DB, pcbName = "STDCDBL", hierarchy = [ @Relationship { segmentRecord = "myCustomerRecordPart"}, @Relationship { segmentRecord = "LocationRecord", parentRecord = "myCustomerRecordPart" }, @Relationship { segmentRecord = "OrderRecord", parentRecord = "myLocationRecordPart" }, ... // database PCB--access by order reference orderReferencePCB DB_PCBRecord { @PCB { pcbType = DB, pcbName = "STDXDBL", secondaryIndex = "STFCORF", //use DL/I name hierarchy = [ @Relationship { segmentRecord = "myCustomerRecordPart"}, @Relationship { segmentRecord = "LocationRecord", parentRecord = "myCustomerRecordPart" }, @Relationship { segmentRecord = "OrderRecord", parentRecord = "myLocationRecordPart" }, ...The pcbName must match an actual DL/I PCB. Now EGL's default behavior will once more be to access a customer record using the customerNo field. To access it using the alternate key, your EGL I/O statement must specify the orderReferencePCB with the usingPCB keyword, as in the following example:
get myCustomer usingPCB orderReferencePCB;You can also have a more complex case, where you want to change the structure of the entire database as your program sees it. (Again, keep in mind that the PCB structure in your EGL program must match an existing DL/I PCB.) Suppose you want the customer database to look like an orders database to your program, with the unique reference number as the key to the orders segment. You can have a PCB with the following structure:
// orders view of customer database ordersPCB DB_PCBRecord { @PCB { pcbType = DB, pcbName = "STDCDBL", secondaryIndex = "STFCORF", //use DL/I name hierarchy = [ @Relationship { segmentRecord = "myOrderRecordPart" }, @Relationship { segmentRecord = "myLocationRecordPart", parentRecord = "myOrderRecordPart" }, @Relationship { segmentRecord = "myCustomerRecordPart", parentRecord = "myLocationRecordPart" }, @Relationship { segmentRecord = "myCreditRecordPart", parentRecord = "myCustomerRecordPart" }, @Relationship { segmentRecord = "myHistoryRecordPart", parentRecord = "myCustomerRecordPart" }, @Relationship { segmentRecord = "myItemRecordPart", parentRecord = "myOrderRecordPart" }]}}; endAssuming the order reference number is unique to each customer and order, and assuming ordersPCB is now your default PCB, you can find the customer for an order by doing a modified path call that removes the qualifications for the location and the customer:
get myOrder, my Customer with #dli{ GU STPCORD (STQCODN = :myOrder.orderReference) STSCLOC STSCCST };
targetBalance MONEY; targetBalance = 10,000.00; get myCrStatus with #dli{ GU STSCCST*D STSCSTA (STFCSBL >= :targetBalance) };You might also want to search based on information in another record. For example, if you wish to look up a customer based on a customer number (invCustNo) in an invoice record (myInvoice) that is of a type (myInvoiceRecordPart) that is a basic record and not part of the database. The code would look something like the following:
get myCustomer with #dli{ GU STSCCST (STQCCNO = :myInvoice.invCustNo) };
Related concepts:
DL/I database support
IMS runtime support
Related reference:
DLIVar
Example DL/I database