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 11 Developing C Applications> 11.2 How to Use C APIs> 11.2.2 Data Searches

11.2.2.2 Obtaining Search Results with a Specified Number of Data Items

In general, Web applications do not display all the search results on a single page, but limit the number of items shown on each page.

In order to control the number of items of data that will be obtained, specify the reply start number and the number of items to return per request as arguments of the ShunSearch function.

The following diagram shows the process for obtaining search results according to the number of data items.

[Figure 11-5 Process for Obtaining Search Results in Specified Quantities of Data Items]

mark1Sample Code

SHUNHSTMT StmtH;
/* Allocate data manipulation handle */
ShunAllocHandle(ConH, &StmtH);                              (1)

/* Execute search */
ShunSearch(StmtH, 11, NULL, 0, 5,                             
           "/document/base/prefecture == 'Sydney'",
           "/document/base/name, /document/base/price",
           NULL,
           &Hit_Cnt, &Return_Cnt, &Returnable_Cnt,
           &Rec_Id_Out, &Data,
           &First_Pos, &Last_Pos);                          (2)

/* Extract search results */
printf("Number of hits              = %d\n", Hit_Cnt);      (3)
if(Hit_Cnt > 0) {
  for (i = 0; i < Return_Cnt; i++) {
    printf("[Result] Item No. %d= %s\n", i+1, Data[i].Data);
  }
}

/* Release data manipulation handle */
ShunFreeHandle(StmtH);                                      (4)

mark2(1) Allocate Data Manipulation Handle

Allocate the data manipulation handle in advance by specifying the connection handle to be used as the parent handle in the ShunAllocHandle function.

mark2(2) Execute the Search

Specify the data manipulation handle, the data acquisition location (acquisition start position or acquisition end position), the maximum number of data items, the search expression and the return expression as parameters of the ShunSearch function and then execute the search.

mark2(3) Extract the Results of the Search

The ShunSearch function returns the address of the search results.

Search results consist of arrays of structures, so data is extracted from these arrays.

Together with the search results, the ShunSearch function also returns a record ID (conductor control information and a reply record identifier) that uniquely identifies an XML document. The record ID is used to extract, delete, and update the entire XML document that corresponds to it.

mark2(4) Release Data Manipulation Handle

After the data search has been performed and the results have been extracted, use the ShunFreeHandle function to release the data manipulation handle.


Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006