edmiRemoteCreateAggrAndWriteAggrElementsBN
EdmiError edmiRemoteCreateAggrAndWriteAggrElementsBN(SdaiServerContext serverContextId, SdaiAppInstance instance, SdaiString attributeName, 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 attribute name. 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. The attribute that will own the aggregate is specified by the <attributeName> argument. If the attribute name is not unique within the actual instance, it must be qualified with the name of the entity from which the attribute was originally inherited.
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 | Specifies a numeric instanceID that uniquely identifies the instance of interest in the remote EDMdatabase |
4 | SdaiString | attributeName | The name of the attribute on which to create an aggregate. Attribute names are case insensitive. When the attribute name is not unique within the instance <currInst>, it must be qualified with the name of the entity from which it was originally inherited. |
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. |
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 | SdaiAggr | newAggrId | 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; 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); /* Create the parent aggregate */ rstat = edmiRemoteCreateAggrAndWriteAggrElementsBN(myContext, salesId, "Sales", 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.