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.1 Obtaining the Number of XML Documents that Match Search Conditions

Sometimes it is desirable to obtain the number of items that match specific criteria before extracting the actual data.

In such cases, specify the conditional expression as the argument of the ShunGetHitCount function and obtain the number of matching items only.

The following diagram shows the process for obtaining the number of XML documents that match specified conditions.

[Figure 11-4 Process for Obtaining the Number of XML Documents that Match Search Conditions]

mark1Sample Code

SHUNHSTMT StmtH;
/* Allocate data manipulation handle */
ShunAllocHandle(ConH, &StmtH);                               (1)
/* Specify the search expression and obtain the number of hits */
ShunGetHitCount(StmtH,                               
"/document/base/city == 'Sydney'",
           &Hit_Cnt);                                        (2)

/* Extract number of hits */
printf("Number of hits              = %d\n", Hit_Cnt);

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

mark2(1) Allocate the 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 and the search expression as parameters of the ShunGetHitCount function and execute the search. Only the number of hits will be returned.

mark2(3) Release the 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