Writes values contained in a memory buffer to elements of an aggregate of any type.
ARRAY: The argument <elementIndex> specifies the index of the first array element to write into. The argument <elements> specifies the number of values to write from the <dataValues> buffer to the ordered array aggregate.
LIST: The values in the <dataValues> will be appended, prepended or inserted into the ordered list aggregate.
BAG and SET: The values in the <dataValues> buffer will be added to the unordered aggregate.
Related functions: edmiRemoteReadAggrElements, edmiRemoteSelectAggrElements, edmiRemoteGetAggrElement
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteWriteAggrElements(SdaiServerContext serverContextId,
SdaiAggr aggrId,
SdaiAggrFunction aggrFunction,
SdaiAggrIndex elementIndex,
SdaiInteger elements,
SdaiPrimitiveType datatype,
SdaiVoid dataValues,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
aggrId |
The numeric aggregateID that uniquely identifies the aggregate of interest in the remote _EDMdatabase{_}. |
aggrFunction |
Legal operations on aggr elements are:
|
elementIndex |
The index of the first ARRAY element to write to. The legal index range for an ARRAY is [L <= index < U] where L is the lower index and U is the upper index in the ARRAY declaration within the underlying Express Schema. |
elements |
The number of elements to write to the aggregate. |
datatype |
The data type (primitive type) of the elements to write into the aggregate |
dataValues |
The address of the memory buffer that contains the elements to write into the aggregates. |
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:
/*
SCHEMA DentalStatus;
ENTITY Tooth;
Fillings : INTEGER;
END_ENTITY;
ENTITY Incisor SUBTYPE OF (Tooth); END_ENTITY;
ENTITY Canin SUBTYPE OF (Tooth); END_ENTITY;
ENTITY Molar SUBTYPE OF (Tooth); END_ENTITY;
ENTITY Wisdom SUBTYPE OF (Molar); END_ENTITY;
ENTITY Patient;
CustomerId : INTEGER;
ToothSet : ARRAY [1:32] OF OPTIONAL Tooth;
END_ENTITY;
END_SCHEMA;
*/
EdmiError rstat;
SdaiServerContext myContext;
SdaiModel modelId;
SdaiInteger nHits, index;
SdaiInstance patientId, molarId;
SdaiAggr toothSet;
/* Define Remote Server Context */
rstat = edmiDefineServerContext("MyRemoteServerContext",
"Johnny", "Dentist", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Get the modelId of the
patient register model */
rstat = edmiRemoteGetModelBN(myContext, "DataRepository",
"PatientRegister", &modelId, NULL);
/* Get the instance Id of the patient
with customerId 8745 */
nHits = 1;
index = 0;
rstat = edmiRemoteFindInstancesBN(myContext, modelId,
"Patient", "CustomerId = 8745",
sizeof(SdaiInstance), &index, &nHits,
&patientId, NULL);
/* Get the patients toothset */
rstat = edmiRemoteGetAttrsBN(myContext, patientId, 0, 1, NULL,
"ToothSet", sdaiAGGR, &toothSet);
/* The patients has got a new wisdom molar */
rstat = edmiRemoteCreateInstanceAndPutAttrsBN(myContext,
"DataRepository", "PatientRegister",
"Wisdom", 1, &molarId, NULL,
"Fillings", sdaiINTEGER, 0);
/* Insert the patients new upper right
wisdom molar (toothSet element 16)
into his toothSet */
rstat = edmiRemoteWriteAggrElements(myContext, toothSet,
ACCESS_BY_INDEX, 16, 1, sdaiINSTANCE,
&molarId, NULL);
. . .