edmiRemoteCreateNestedTypedAggr
Â
EdmiError edmiRemoteCreateNestedTypedAggr(SdaiServerContext serverContextId, SdaiAggr parentAggr, SdaiAggrFunction aggrFunction, SdaiInteger index, SdaiSelect pSel, SdaiAggr *aggrId, SdaiInvocationId *edmiInvocationId);
Creates a typed aggregate and inserts it as an element in an already existing aggregate. The existing aggregate is denoted the parent aggregate. The nested aggregate to be created is denoted a child aggregate of its parent aggregate .Nested typed aggregates are required when the data type specification of the elements of their parent aggregate is not uniquely defined in the edmModels underlying Express Schema. This may only happen when the declared aggregate elements of the parent aggregate are of type SELECT. When creating a nested typed aggregate, a struct of type tSdaiSelect with a type specification of the aggregate elements must be supplied. A numeric aggregateID will be returned from the function. This id uniquely identifies the nested typed aggregate within the remote EDMdatabase. This 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 parent aggregate that will be the owner of the nested aggregate is specified by its aggregateId in the <parentAggr> argument. AggregateIDs may not be handled as a plain data values. Nested aggregates must be created within their parent aggregates. Child aggregateIds may be retrieved by EDMinterface Get operations, but they may not be used to populate parent aggregates by means of EDMinterface Put operations. This operation is only applicable to aggregates owned by application instances.
Â
Arguments
Type | Name | Comment |
 SdaiServerContext | serverContextId | Context identification, from edmiDefineServerContext |
 SdaiAggr | parentAggr | A numeric aggregateId that uniquely identifies the parent typed aggregate in which this nested typed aggregate is to be created. Any level of nesting is allowed. Only the first level must be created with edmiRemoteCreateTypedAggr. All subsequent levels must be created by this function. Hence, the parent aggregate may be either a plain typed aggregate or a nested typed aggregate. |
 SdaiAggrFunction | aggrFunction | Determines the insert point of the created nested aggregate in its parent aggregate. The following is a description of each of the legal values of this argument.
|
 SdaiInteger | index | A parent aggregate element position that is used to determine the insertion point of the created nested aggregate. |
 SdaiSelect | pSel | Pointer to a locally allocated tSdaiSelect data structure that contains the type specification of the typed aggregate elements. The aggregate is typed with a path of pSel->nTypes elements. The path must be specified in the buffer pointed to by pSel->typeList. Each element in this buffer is a numeric typeID identifying a defined type instance in the remote EDMdatabase . The last specified typeID in the pSel->typeList buffer defines the element type of the typed aggregate. |
 SdaiAggr | aggrId | Variable that will receive the aggregateId that uniquely identifies the nested typed aggregate in the remote EDMdatabase |
 SdaiInvocationId | edmiInvocationId | Currently not used. |
Return Value
Â
Options
 Â
Option | Comment |
Option name | Comment |
Â
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.
Â
Â