You can also use the add statement to place multiple segments into a DL/I database from a dynamic array of DLISegment records.

add myCustomer, myLocation, myOrder;
ISRT STSCCST*D (STQCCNO = :myCustomer.customerNo)
STSCLOC (STQCLNO = :myLocation.locationNo)
STPCORD
// define DLI Segment records using the hostVarQualifier property
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;
//build a segment search parameter
myCustomer.customerNo = "005001";
myLocation.locationNo = "000022";
//fill the fields in the order record
fillOrder(myOrder);
//add the new order record
try
add myOrder;
onException(dex DLIException)
myErrorHandler(dex);
end
ISRT STSCCST (STQCCNO = :myCustomer.customerNo)
STSCLOC (STQCLNO = :myLocation.locationNo)
STPCORD
Qualified segment search parameters (SSAs) for customer and location identify the parent segments for the new order segment. DL/I adds the new order segment in a position that is determined by the keyItem field for that segment, the orderDateNo (STQCODN).
if (myOrder is unique)
...
end
Possible runtime errors include the following: