Returns the number of elements in an aggregate in a remote EDMdatabase.
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteGetMemberCount(SdaiServerContext serverContextId,
SdaiAggr aggrId,
SdaiVersion version,
SdaiInteger *members,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
aggrId |
A numeric aggregateID that uniquely identifies the aggregate of interest in the remote _EDMdatabase._ |
version |
The version of the edmModel to apply this function call on. The <version> parameter is a numeric sequence number counting from one by increments of one for each new model version that is created. A zero model version number means the current version. |
members |
A variable that will receive the number of elements in the aggregate. |
edmiInvocationId |
Currently not used. |
Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an _EDMinterface_ error code. Use edmiGetErrorText to get the error text corresponding to the error code.
Example:
Example:
/*
SCHEMA Employees
ENTITY person;
Name : STRING;
Age : INTEGER;
END_ENTITY;
ENTITY Manning;
DivisionStaff : ARRAY [0:4] OF SET OF person;
END_ENTITY;
END_SCHEMA;
*/
int i;
EdmiError rstat;
SdaiInteger nHits, nEmployees, index;
SdaiServerContext myContext;
SdaiInstance manningId;
SdaiAggr parentAggrId, childAggrId;
SdaiQueryResult qexRes;
SdaiAggrType aggrType;
SdaiInteger lowerBound, upperBound, members;
SdaiInstance elementId, domainId;
SdaiBoolean isOptional, isUnique;
SdaiPrimitiveType dataType;
/* Create Server Context */
rstat = edmiDefineServerContext("MyContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Get the manningId instance. It is assumed that
there is only one instance of type Manning */
index = 0;
nHits = 1;
rstat = edmiRemoteSelectInstances(myContext, "AdminRepository",
"Employees", "Manning", NULL, ONLY_INSTANCE_IDS,
NULL, NULL, NULL, &index, &nHits, &qexRes,
NULL, NULL, NULL, NULL);
manningId = qexRes->instanceIds[0];
edmiFreeQueryResult(qexRes);
/* Get the parent aggregate Id */
rstat = edmiRemoteGetAttrsBN(myContext, manningId, 0, 1, NULL,
"DivisionStaff", sdaiAGGR, &parentAggrId);
/* Get the parent aggregate descriptor */
rstat = edmiRemoteGetAggrDescr(myContext, parentAggrId,
&aggrType, &lowerBound, &upperBound,
&elementId, &domainId, &isOptional,
&isUnique, &dataType, &members, NULL);
/* Count the employees in all divisions */
for (i=lowerBound; i<=upperBound; i++) {
rstat = edmiRemoteGetAggrElement(myContext, parentAggrId,
0, i, sdaiAGGR, &childAggrId, NULL);
rstat = edmiRemoteGetMemberCount(myContext,
childAggrId, 0, &nEmployees, NULL);
printf("\nDivision %d: %d employees.", i, nEmployees);
}
. . .