sdaiGetAggrByIndex
Returns the data value in the actual aggregate element. The specified primitive type <valueType> must be the same as the actual data type in the aggregate element or a compatible data type. The primitive type sdaiSELECT can be used to get all data types. The primitive type sdaiADB can be used to get all data types except typed value. The primitive type sdaiINTEGER is compatible with sdaiREAL, and sdaiBOOLEAN is compatible with sdaiLOGICAL, hence conversion between these compatible data types will be performed when required.
This operation is applicable to ordered aggregates, i.e. ARRAY and LIST type aggregates. The actual aggregate element is specified by the element index. Element index zero is the lowest index in a LIST, hence the legal indexes for a LIST are: 0 <= index <= number of elements in LIST. The legal index range for ARRAY is as found in the actual ARRAY declaration in the related EXPRESS schema.
The model that holds the actual aggregate must be open before this function can be successfully performed.
Related functions: sdaiGetAggrByIterator , edmiGetAggrElement
Header:
#include "sdai.h"
Prototype:
void *sdaiGetAggrByIndex(SdaiOrderedCollection aggregate,
SdaiInteger index,
SdaiPrimitiveType valueType,
void *value);
Arguments:
aggregate |
A numeric aggregateID that uniquely identifies the aggregate instance in the EDMdatabase. |
index |
An integer that denotes the aggregate element index in the aggregate to read the data value from. |
valueType |
The data type, i.e. the primitive type of the data value to be retrieved. This <valueType> must be the same or a compatible type of the primitive type of the value in the actual aggregate element. The primitive type sdaiSELECT can be used to read all data types. The primitive type sdaiADB can be used to read all data types except typed values. |
value |
The variable that will hold a copy of the data value read from the actual aggregate element. The type of <value> must be the same or a compatible type of <valueType>. |
Returns:
void * = address of <value> : operation successfully performed.
void * = NULL: error during operation – use sdaiErrorQuery function to get error reason.
Example:
SdaiOrderedCollection aggregate;
void *p;
SdaiString myString;
...
p = sdaiGetAggrByIndex(aggregate, 5, sdaiSTRING, &myString);
if (p == NULL) {
/* Error in operation */
printf("\nError: %s in sdaiGetAggrByIndex \n",
edmiGetErrorText(sdaiErrorQuery()));
goto error;
}
. . .