Returns buffer with the indexes of all the elements of an aggregate that matches given Express-X conditional statement. This function only handles aggregates with primitive data type elements.
Header:
#include "sdai.h"
Prototype:
EdmiError edmiSelectAggrElements(SdaiAggr aggrId,
SdaiString condition,
SdaiInteger options,
SdaiInteger maxBufferSize,
SdaiInteger *index,
SdaiInteger *hits,
SdaiInteger *buffer);
Arguments:
aggrId |
The numeric aggregateID that uniquely identifies the aggregate of interest in the EDMdatabase. This may be any type of aggregate, both persistant and scratch with elements of primitive data types. |
condition |
A conditional statement, written in Express-X, that the aggregate elements shall match. References to the element it self is done by the symbol SELF. A string comparing condition may therefore be written "SELF = 'SCHMIDT'" or "SELF LIKE 'SCHMIDT'" or even "xpxLIKE(SELF, 'SCHMIDT')" |
options |
Not used. |
maxBufferSize |
Specifies the size (in number of bytes) of the buffer used for receiving matching elements. The number of elements may never exceed the number that fits into a buffer with the size specified in this argument. |
index |
In: The index of the aggregate element to start reading from. The index of the first element in the actual aggregate will always be indexed zero, regardless of the aggregate type. Hence the legal index range is: 0<= index < number of elements in the aggregate. |
hits |
In: Specifies the maximum number of matching elements to return. If this number is greater than the limitation specified by the <maxBufferSize> argument, then the maximum number of hits will be calculated from the <maxBufferSize> argument. |
buffer |
The buffer, allocated by the calling application, that will receive the value of each returned matching element. Use the <maxBufferSize> or <hits> argument to prevent writing outside this buffer. |
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:
#define NOBUFF 1024
int i;
EdmiError rstat;
SdaiAggr myArrayId;
SdaiInteger buff[NOBUFF];
SdaiInteger buffsize = (NOBUFF * sizeof(SdaiInteger));
SdaiInteger index = 0;
SdaiInteger nHits = NOBUFF;
. . .
if (rstat = edmiSelectAggrElements(myArrayId, "SELF = 'SCHMIDT'",
0, buffsize, &index, &nHits, &buff[0])) {
printf("\nError %d in edmiSelectAggrElements: %s", rstat,
edmiGetErrorText(rstat));
goto err;
}
if (! nHits) {
printf("\nNo persons with the name 'SCHMIDT' found");
}else {
printf("\n%d persons found with the name 'SCHMIDT'");
printf("\nLocated in the array element(s) number:");
for (i=0;i<nHits;i++) {
printf("%d ", buff[i]);
}
}
. . .