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 10 Developing .NET Applications> 10.3 How to Use .NET APIs> 10.3.3 Updating Data

10.3.3.3 Updating Data by Specifying Record IDs

Use the Update method to update XML documents.

The .NET APIs use record IDs to update data. The record IDs of the data to be updated have to be obtained before updating the data. 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 10-15 Flow of the Process for Updating Data Specifying a Record ID]

mark1Sample Code for C# .NET

ShunService service = new ShunService();
service.Connect();

ShunSearchRequirement req = new ShunSearchRequirement();
req.QueryExpression = "/document/base/prefecture == 'Sydney'";
req.ReturnExpression = "/";

ShunResultSet rs = service.Search( req );                                       (1)
ShunRecord updateRecord = null;                                                 (1)
foreach ( ShunRecord record in rs.Records ) {                                   (1)
  if ( record.Data == "Hotel 1" ) {                                             (1)
    updateRecord = record;                                                      (1)
  }
}
updateRecord.Data = updateData ;                                                (2)
ShunRecordCollection recCol = new ShunRecordCollection();                       (3)
recCol.Add( updateRecord );                                                     (4)

service.Update( recCol );                                                       (5)

service.Disconnect();

mark1Sample Code for VB .NET

Dim service As New ShunService()
service.Connect()

Dim req As New ShunSearchRequirement()
req.QueryExpression = "/document/base/prefecture == 'Sydney'"
req.ReturnExpression = "/"

Dim rs As ShunResultSet =  service.Search( req )                                 (1)
Dim updateRecord As ShunRecord = Nothing                                         (1)
For Each record As ShunRecord In rs.Records                                      (1)
  If record.Data = "Hotel 1" Then                                                (1)
    updateRecord = record                                                        (1)
  End If
Next
updateRecord.Data = updateData                                                   (2)
Dim recCol As New ShunRecordCollection()                                         (3)
recCol.Add( updateRecord )                                                       (4)
service.Update( recCol )                                                         (5)

service.Disconnect()

mark2(1) Obtain the ShunRecord Object to be Updated

Obtain the ShunRecord object to be updated.

mark2(2) Specify the Data to be Updated

Set the XML documents to be updated at the ShunRecord object.

Use the following methods to set the XML documents. Refer to the table below for the methods that can be used to update XML documents.

[Table 10-24 List of Methods for Setting XML Documents]

Method or property

Function

ShunRecord(String data)

Specifies XML documents to the arguments of the constructor and creates the ShunRecord object.

ShunRecord(ShunRecordID recordID, String data)

Specifies record IDs and XML documents to the arguments of the constructor and creates the ShunRecord object.

ShunRecord(ShunRecordID recordID, Stream stream)

Specifies record IDs and XML documents to the arguments of the constructor and creates the ShunRecord object.

Data property

Specifies the XML documents.

mark2(3) Create a ShunRecordCollection Object

Create a ShunRecordCollection object.

mark2(4) Set a ShunRecord Object

Set the ShunRecord object at the ShunRecordCollection object.

Use the following methods to set the ShunRecord object. Refer to the table below for the methods that can be used to update XML documents.

[Table 10-25 List of Methods for Setting ShunRecord Object]

Method or property

Function

Add(ShunRecord record)

Adds the ShunRecord to the end of ShunRecordCollection.

AddRange(ShunRecord[] records)

Copies the element of ShunRecord array to the end of ShunRecordCollection.

Insert(int index, ShunRecord record)

Inserts the ShunRecord at the index position specified in the ShunRecordCollection.

Item[int index]

Replaces the ShunRecord that the index position is specified.
This property will be the indexer of ShunRecordCollection class for C# .NET.

mark2(5) Add the Data

Use the Update method to execute the update process.


Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006