sdaiCreateNestedAggrByIndex
Creates an aggregate instance and sets the created aggregate as an element in an already existing aggregate instance, i.e., a nested aggregate is the result of this operation. The already existing aggregate will be the parent aggregate of the new created aggregate and the new created aggregate will be a child aggregate of the already existing aggregate. The position of the new aggregate in the parent aggregate is specified by an aggregate element index. If an aggregate is already existing in this position in the parent aggregate, this existing aggregate will be deleted before the new one is created and inserted in the parent aggregate.
Any levels of nesting is legal provided that the levels of nesting is according to the actual attribute declaration of the attribute that owns the outer-most aggregate, i.e., the aggregate created by the sdaiCreateAggr or sdaiCreateAggrBN operation. The actual aggregate type to be created is defined by the attributed declaration in the related EXPRESS schema.
This operation is legal for ARRAY and LIST aggregates. When this operation is applied on a LIST aggregate, it can only be used to replace existing aggregates or appending the new aggregate at the end of the parent aggregate. 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.
A numeric aggregateID that uniquely identifies the new created aggregate instance in the EDMdatabase will be the returned function value. This aggregateID should be used to identify this particular aggregate instance in subsequent EDMinterface operations. An aggregateID is persistent and fixed, i.e. it is constant throughout the lifetime of the actual aggregate instance.
An aggregateID can never be used as a data value in any of the _EDMinterface_ put operations, it can only be returned as data value in _EDMinterface_ get operations.
This operation is only applicable to aggregates owned by application instances.
The model that will hold the new created aggregate must be open for write access before this function can be successfully performed.
See related function: sdaiCreateAggr , sdaiCreateAggrBN , sdaiCreateNestedAggr, sdaiCreateNestedAggrByIterator , edmiCreateTypedAggr , edmiCreateTypedAggrBN , edmiCreateNestedTypedAggr , edmiCreateNestedTypedAggrByIndex , edmiCreateNestedTypedAggrByIterator , edmiCreateScratchAggr , edmiCreateNestedScratchAggr , edmiCreateSubtypeAggr , edmiCreateSubtypeAggrBN , edmiCreateUnionAggr , edmiCreateUnionAggrBN
Header:
#include "sdai.h"
Prototype:
SdaiAggr sdaiCreateNestedAggrByIndex(SdaiOrderedCollection aggregate
SdaiInteger index);
Arguments:
aggregate |
A numeric aggregateID that uniquely identifies an aggregate instance in the EDMdatabase. This aggregate becomes the parent aggregate of the new created aggregate. The parent aggregate must be an ARRAY or a LIST aggregate. The new created aggregate will be inserted as an element in the aggregate specified by this argument. |
index |
An integer that denotes the aggregate element index in the parent aggregate that will receive the new created aggregate. |
Returns:
A numeric aggregateID that uniquely identifies the new created aggregate instance in the EDMdatabase.
aggregateID != 0 : operation successfully performed.
aggregateID = 0 : operation failed, use sdaiErrorQuery function to get error reason.
Example:
SdaiAppInstance anInst;
SdaiAggr parentAggr, aggrId;
...
parentAggr = SdaiCreateAttrBN(anInst, "Attr");
. . .
aggrId = sdaiCreateNestedAggrByIndex (parentAggr, 1);
if (! aggrId) {
/* Error in operation */
printf("\nError: %s in sdaiCreateNestedAggrByIndex \n",
edmiGetErrorText(sdaiErrorQuery()));
goto error;
}
. . .