edmiRemoteFindInstancesBN
EdmiError edmiRemoteFindInstancesBN(SdaiServerContext serverContextId, SdaiModel modelId, SdaiString entityName, SdaiString condition, SdaiInteger maxBufferSize, SdaiInteger *index, SdaiInteger *numberOfHits, SdaiInstance *resultBuffer, SdaiInvocationId *edmiInvocationId);
Search in a specified remote edmModel for instances of a given type that match a specified condition. The condition must be a simple logical expression addressing only the simple type attribute values of the instances. A NULL or empty string condition will match All instances of the specified type in the specified edmModel. Each matching instance is identified by its unique numeric instanceID. All instances of a the specified type is held in an entity extent instance aggregate. It is this instance aggregate that will be queried for matching instances. The index of the first instance aggregate element to check, and the maximum number of matching instances to return, are specified as input arguments to the function. The actual number of matching instances returned and the "index of the last returned matching instance in the entity extent instance aggregate" are returned from the operation. This makes it possible to query through huge amounts of instances in an entity extent aggregate by means of a loop where each iteration handles small subset of the total instance aggregate. See the example below. When the <maxBufferSize> argument is zero and the <resultBuffer> argument is NULL. Nothing but the number of matching instances will be returned.
Arguments
1 | Type | Name | Comment |
2 | SdaiServerContext | serverContextId | Context identification, from edmiDefineServerContext |
3 | SdaiModel | modelId | The unique numeric modelID of the edmModel within the remote EDMdatabase to query for matching instances. |
4 | SdaiString | entityName | Name of the entity that defines the instance type to query. Entity names are case insensitive. The entity must be defined in the underlying Express Schema of the edmModel specified by the <modelId> argument. |
5 | SdaiString | condition | The condition that the instances in the entity extent aggregate shall match. A NULL or empty string condition will match all the instances. The condition statement must be on the form "attribute = value" |
6 | SdaiInteger | maxBufferSize | The size of the buffer (in number of bytes) in which all the matching instances will be returned. The number of returned elements will never exceed the maximum number of instances that may be contained by a buffer with this size. |
7 | SdaiInteger | index |
|
8 | SdaiInteger | numberOfHits |
|
9 | SdaiInstance | resultBuffer | A buffer, allocated by the calling application, that will receive the instanceIDs of the matching instances. Use the <maxBufferSize> argument to prevent writing past the end of this buffer. |
10 | SdaiInvocationId | edmiInvocationId | Currently not used. |
Return Value
Options
Example
#define S_BUFFSIZE 10 int i; SdaiModel modelId; EdmiError rstat; SdaiServerContext myContext; SdaiInstance buff[10]; SdaiInteger index, nHits, nTot; /* Create Server Context */ rstat = edmiDefineServerContext("MyContext", "Johnny", "Supervisor", "cf37ftr", "TCP", "9090", "MyServerHost", NULL, NULL, NULL, NULL, NULL, &myContext); /* Get id of the MySocialRelations model */ rstat = edmiRemoteGetModelBN(myContext, "MyRepository", "MySocialRelations", &modelId, NULL); /* Find carpenters among my friends */ nTot = 0; index = 0; nHits = S_BUFFSIZE; while (nHits == S_BUFFSIZE) { rstat = edmiRemoteFindInstancesBN(myContext, modelId, "MyFriends", "PROFESSION = 'Carpenter'", S_BUFFSIZE * sizeof(SdaiInstance), &index, &nHits, &buff[0], NULL); /* Get names and phone numbers */ for (i=0;i<nHits;i++) { SdaiString _attrName[3] = {"FIRST_NAME", "LAST_NAME", "PHONE_NO"}; tSdaiSelect _sel[3]; SdaiSelect _attrVal[3] = {&_sel[0], &_sel[1], &_sel[2]}; rstat = edmiRemoteGetAttrsBNEx(myContext, buff[i], 0, 3, _attrName, _attrVal, GET_ATTRS, NULL); printf("\n%s %s, Phone No. %s", _sel[0].value.stringVal, _sel[1].value.stringVal, _sel[2].value.stringVal); } nTot += nHits; ++index; } printf ("\n%d carpenters found among my friends!"); . . .
See also
Filter by label
There are no items with the selected labels at this time.