Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX - |
Contents
Index
![]() ![]() |
Part 1 The Basic for Developing Application | > Chapter 6 Direct Access Function | > 6.4 Searching Data by Direct Access Key |
The ShunSearchKey function is used in the direct search for C API.
The following figure shows the flow of the direct search for C API.
/* This program assumes that the following variables have been declared */ /* pKey : Structure array for setting the direct access keys */ SHUNHSTMT StmtH; /* Allocate data manipulation handle */ ShunAllocHandle(ConH, &StmtH); /* Use direct access key to perform search */ pKey[0].Key = "20061101,00000001"; (1) pKey[0].Key_Len = strlen( pKey[0].Key ); pKey[1].Key = "20061101,00000002"; (1) pKey[1].Key_Len = strlen( pKey[1].Key ); pKey[2].Key = "20061101,00000003"; (1) pKey[2].Key_Len = strlen( pKey[2].Key ); ShunSearchKey(StmtH, "key1", SHUN_KEY_COMPLETE_MATCH, 3, pKey, "/", &Return_Cnt, &Rec_Id_Out, &Data, &Key_Out); (2) /* Extract number of hits*/ printf("Number of results = %d\n", Return_Cnt); if(Return_Cnt > 0) { for (i = 0; i < Return_Cnt; i++) { printf("[Result] Item No.%d = %s\n", i+1, Data[i].Data); (3) } } /* Release data manipulation handle */ ShunFreeHandle(StmtH); |
Set the direct access key at the SHUNKEY structure.
Specify the data manipulation handle, the direct access key name, the return expression, the number of requested direct access key and the requested direct access key array as parameters of the ShunSearchKey function and then execute the search.
Specify multiple direct access keys with the ShunSearchKey function to obtain multiple XML documents at a time.
The ShunSearchKey function returns the address of the search results.
Search results consist of arrays of structures, so data is extracted from these arrays. If an XML document does not exist, NULL is set in the pointer to the element data in the array, and the data size is set to zero.
Refer to J.3.2 Searching Data Using Direct Access Key for the sample program of the direct access.
Contents
Index
![]() ![]() |