Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX -
Contents Index PreviousNext

Part 2 Developing Applications by APIs> Chapter 9 Developing Java Applications> 9.3 How to Use Java APIs> 9.3.3 Updating Data

9.3.3.3 Updating Data by Specifying Record IDs

Use the prepareUpdateRecordID method to update XML documents.

The Java APIs use record IDs to update data. Before updating data, use the getRecordID method to obtain the record IDs of the data to be updated. The process of using a record ID to update an XML document refers to replacing an existing XML document with a new XML document. It is not possible to update part of the data contained in an existing XML document.

The following diagram shows the process for updating data specifying a record ID.

[Figure 9-15 Flow of the Process for Updating Data Specifying a Record ID]

mark1Sample Code

ShunConnection con = new ShunConnection();

ShunPreparedRecordID prid = con.prepareUpdateRecordID();        (1)
prid.add(recordID, updateData);                                 (2)
prid.updateByRecordID();                                        (3)
prid.close();                                                   (4)

con.close();

mark2(1) Create a ShunPreparedRecordID Object

The prepareUpdateRecordID method is used to create a ShunPreparedRecordID object.

mark2(2) Specify the Record ID and the Data to be Updated

The add method is used to specify the record ID and the data to be updated. The record ID is obtained using the getRecordID method.

Multiple record IDs and items of data to be updated can be specified with the add method. If the same record ID already exists, both the record ID and the data to be updated will be overwritten if that record ID is specified again.

By specifying multiple record IDs and items of data to be updated with the add method, multiple XML documents can be updated at once.

mark2(3) Execute the Update

Use the updateByRecordID method to execute the update process.

mark2(4) Release the ShunPreparedRecordID Object

Use the close method of the ShunPreparedRecordID object to release the object when it is no longer required.

mark1Sample Codes for Studio

The following are entry examples available when Studio is used.

Business Class

String recordID = dataBean.getDetailButton();
ShunConnection con = new ShunConnection();

ShunsakuAccessController controller = new ShunsakuAccessController(con);
controller.update(recordID, updateData);

con.close();

Shunsaku Access Class

public void update(String recordID, String updateData)
                                           throws ShunException {

   ShunPreparedRecordID prid = con.prepareUpdateRecordID();           (1)
   prid.add(recordID, updateData);                                    (2)
   prid.updateByRecordID();                                           (3)
   prid.close();                                                      (4)

}

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006