Updating data in a IMS Universal DL/I driver application

Use the replace methods in the PCB interface to update an existing segment in the database.

In the IMS Universal DL/I driver, the replace methods provide functionality similar to the DL/I REPL call. The replace methods will return an IMS status code indicating the results of the DL/I operation.
The following are the general steps to update an existing segment in the database:

Procedure

  1. Obtain an SSAList instance from the PCB instance representing the database.
  2. Optionally, you can add qualification statements to the SSAList instance. See Specifying segment search arguments using the SSAList interface for more information.
  3. Get a Path instance by using the SSAList instance from the previous steps and calling the getPathForRetrieveReplace method.
  4. Using the Path instance from the step above, set the field values to update for the segment.
  5. Perform a Hold operation before issuing the replace call. The Hold operation can be a getUnique, getNext, or getNextWithinParent method call.
  6. Call the replace method to update the segment.

IMS Universal DL/I driver update example

The following code fragment illustrates how to use the replace method to update a patient's name in patient records where the patient name is ANDREA SMITH, the ward name is SURG, and the hospital name is ALEXANDRIA.

SSAList ssaList = pcb.getSSAList("HOSPITAL","PATIENT");
ssaList.addInitialQualification("HOSPITAL","HOSPNAME",SSAList.EQUALS,"ALEXANDRIA");
ssaList.addInitialQualification("WARD","WARDNAME",SSAList.EQUALS,"SURG");
ssaList.addInitialQualification("PATIENT","PATNAME",SSAList.EQUALS,"ANDREA SMITH");

Path path = ssaList.getPathForRetrieveReplace();
if(pcb.getUnique(path, ssaList, true)){
   path.setString("PATNAME", "ANDREA TAYLOR");
   pcb.replace(path);
}
while(pcb.getNext(path, ssaList, true){
   path.setString("PATNAME", "ANDREA TAYLOR");
   pcb.replace(path);
}
Note: To persist changes made to the database, your application must call the commit method prior to deallocating the PSB, otherwise the changes are rolled back up to the last point the commit method was called.