sdaiCreateInstance
Create a new entity instance of the specified instance type in a specified model in the EDMdatabase.
All the attributes of the created instance are initially unset, i.e., the attribute values are indeterminate. The sdaiTestAttr and sdaiTestAttrBN functions will return sdaiFALSE for all attributes of the created instance until the attribute values have been set with one of the functions: sdaiPutAttr , sdaiPutAttrBN , sdaiPutAttrs , sdaiPutAttrsBN , sdaiCreateAggr , sdaiCreateAggrBN .
A numeric instanceID that uniquely identifies the entity instance in the EDMdatabase will be the returned function value. This instanceID should be used to identify this particular instance in subsequent EDMinterface operations. An instanceID is persistent and fixed, i.e. it is constant throughout the lifetime of the actual instance.
An instanceID will not be reused before the actual model that holds the particular instance identified by this instanceID is deleted.
This function is applicable only to data models.
The model that holds the created instance must be open for write access before this function can be successfully performed.
Related function: sdaiCreateInstanceBN , edmiCreateScratchInstance , edmiCreateScratchInstanceBN , sdaiDeleteInstance
Header:
#include "sdai.h"
Prototype:
SdaiAppInstance sdaiCreateInstance(SdaiModel model,
SdaiEntity entity);
Arguments:
model |
A numeric modelID that uniquely identifies a model in the EDMdatabase. The actual model must be a data model that is currently open for write access . |
entity |
A numeric entityID that uniquely identifies an entity definition instance in a dictionary model in the EDMdatabase. This entity definition must be defined in the underlying schema of the actual model specified by the <model> argument. |
Returns:
A numeric instanceID that uniquely identifies the new created entity instance in the EDMdatabase. This instanceID should be used to identify the particular instance for subsequent EDMinterface operations.
instanceID != 0 : operation successfully performed.
instanceID = 0 : operation failed, use sdaiErrorQuery function to get error reason.
Example:
SdaiAppInstance currInst;
SdaiModel model;
SdaiEntity entity;
...
currInst = sdaiCreateInstance(model, entity);
if (! currInst) {
/* Error in operation */
printf("\nError: %s in sdaiCreateInstance \n",
edmiGetErrorText(sdaiErrorQuery()));
goto error;
}
. . .