edmiRemoteCreateAggrAndWriteAggrElements
EdmiError edmiRemoteCreateAggrAndWriteAggrElements(SdaiServerContext serverContextId, SdaiAppInstance instance, SdaiAttr attributeId, SdaiAggrIndex elementIndex, SdaiInteger elements, SdaiPrimitiveType datatype, SdaiVoid dataValues, SdaiAggr *newAggrId, SdaiInvocationId *edmiInvocationId);
Creates an aggregate on an explicit attribute of an instance within an edmModel in the remote EDMdatabase and inserts any number of given data values in it . The attribute on which to create the aggregate must be identified by its attributeId. The type of aggregate that results from this operation is determined by the aggregate declaration in the underlying Express Schema of the edmModel. Suppose the declaration of the attribute myAttr is;
myAttr : LIST [1:3] OF STRING;
Then, this function would create a list of up to three string elements on the attribute myAttr. A numeric aggregateID will be returned from the function. This id uniquely identifies the aggregate within the remote EDMdatabase. The aggregateID will remain unchanged throughout the lifetime of the aggregate and may be used to identify the aggregate in subsequent calls to EDMinterface API functions. AggregateIDs may not be considered plain data values. Aggregates must be created on the explicit attributes of entities that have been predeclared to hold them in the underlying Express Schema of the edmModel. An aggregateId may be retrieved by an EDMinterface Get operation, but it may not be used to populate other attributes by means of EDMinterface Put operations.
Arguments
1 | Type | Name | Comment |
2 | SdaiServerContext | serverContextId | Context identification, from edmiDefineServerContext |
3 | SdaiAppInstance | instance | A numeric instanceID that uniquely identifies an application instance in the remote EDMdatabase. |
4 | SdaiAttr | attributeId | A numeric attributeID that uniquely identifies an attribute definition instance in the remote EDMdatabase. |
5 | SdaiAggrIndex | elementIndex | The aggregate element at which to start inserting the values given in the <dataValues> aggregate. This argument is applicable for Array aggregates only. Note that the index range of an array is declared in the underlying Express Schema of the edmModel. The declared lower and upper bounds of the index range for an array may also be obtained by the function edmiRemoteGetAggrDescr. |
6 | SdaiInteger | elements | The number of data elements to write to the created aggregate. |
7 | SdaiPrimitiveType | datatype | Currently, this function can only handle the datatype sdaiSELECT. |
8 | SdaiVoid | dataValues | A buffer of tSdaiSelect data structures. Each element must contain one of the values to be written to the created aggregate. |
9 | SdaiAttr | newAggrId | A variable that will receive the aggregateId that uniquely identifies the created aggregate in the remote EDMdatabase. |
10 | SdaiInvocationId | edmiInvocationId | Currently not used. |
Return Value
Options
Example
SCHEMA Accounts TYPE tUSD = REAL; END_TYPE; TYPE tEUR = REAL; END_TYPE; TYPE tNOK = REAL; END_TYPE; TYPE tAmount = SELECT (tUSD, tEUR, tNOK); END_TYPE; ENTITY Turnover; Sales : ARRAY [0:4] OF ARRAY [1:12] OF tAmount; END_ENTITY; END_SCHEMA; */ #define S_NOOF_DIVISIONS 5 #define S_JANUARY 1 #define S_FEBRUARY 2 #define S_MARCH 3 int i; EdmiError rstat; SdaiServerContext myContext; SdaiInstance salesId; SdaiAttr attrId; SdaiAggr parentAggrId; SdaiAggr childAggrId[S_NOOF_DIVISIONS]; SdaiType tAmountId; tSdaiSelect sel; SdaiSelect salesAmount = &sel; /* Create Server Context */ rstat = edmiDefineServerContext("MyContext", "Johnny", "Supervisor", "cf37ftr", "TCP", "9090", "MyServerHost", NULL, NULL, NULL, NULL, NULL, &myContext); /* Create instance of sales */ rstat = edmiRemoteCreateInstanceAndPutAttrsBN(myContext, "AdminRepository", "Economy", "Turnover", 0, &salesId, NULL); /* Get the attribute Id */ rstat = edmiRemoteGetAttrDefinitionBN(myContext, "Accounts", "Turnover", "Sales", &attrId, NULL); /* Create the parent aggregate */ rstat = edmiRemoteCreateAggrAndWriteAggrElements(myContext, salesId, attrId, 0, 0, 0, NULL, &parentAggrId, NULL); /* Get the type Id of tAmount */ rstat = edmiRemoteGetDefinedTypeBN(myContext, "Accounts", "tAmount", &tAmountId, NULL); /* Create child aggregates for all company divisions */ salesAmount->nTypes = 1; salesAmount->type = sdaiREAL; salesAmount->typeList = &tAmountId; salesAmount->value.realVal = 0; for (i=0;i<S_NOOF_DIVISIONS;i++) { rstat = edmiRemoteCreateNestedTypedAggr(myContext, parentAggrId, ACCESS_BY_INDEX, i, salesAmount, &childAggrId[i], NULL); } /* Insert sales numbers for each division for the first month of the year */ for (i=0;i<S_NOOF_DIVISIONS;i++) { SdaiReal _sales[5] = {123.2, 45.4, 334.0, 11.9, 98.7}; salesAmount->value.realVal = _sales[i]; rstat = edmiRemoteWriteAggrElements(myContext, childAggrId[i], ACCESS_BY_INDEX, S_JANUARY, 1, sdaiSELECT, salesAmount, NULL); } . . .
See also
Filter by label
There are no items with the selected labels at this time.