Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »


 
This operation creates a scratch instance and optionally set the specified attribute values of the created instance. Hence this operation is a combination of edmiCreateScratchInstanceBN and sdaiPutAttrsBN operations. A scratch instance is located in the scratch model, i.e., scratch instances will not be written to the persistent EDMdatabase.
All EDMinterface access operations defined for persistent instances are applicable on scratch instances.
The scratch model is a volatile model that is deleted when the session is closed or the database is closed. The scratch model can hold instances of any instance types defined by any dictionary models in the EDMdatabase. Each open session has it own unique scratch model, hence the data in a scratch model cannot be shared between concurrent users of an EDMdatabase. The scratch model will implicitly be created and open for write access when the session is opened.
The dictionary model that specified by the <schemaName> must be open before this operation can be successfully performed.
A scratch instance can be deleted by the sdaiDeleteInstance , edmiDeleteInstanceAndReferences , edmiDeleteAllScratchInstancesOfSchema , edmiDeleteAllScratchInstancesOfSchemaBN operations. All scratch instances are deleted when the open session is closed or when the database is closed.
Related functions: edmiCreateScratchInstance , edmiCreateScratchInstanceBN , edmiCreateScratchInstanceAndPutAttrs , sdaiDeleteInstance , edmiDeleteInstanceAndReferences , edmiDeleteAllScratchInstancesOfSchema , edmiDeleteAllScratchInstancesOfSchemaBN , sdaiPutAttrs
Header:
#include "sdai.h"
Prototype:
SdaiAppInstance edmiCreateScratchInstanceAndPutAttrsBN(SdaiString schemaName, 
                                                        SdaiString entityName, 
                                                        SdaiInteger numberAttr, 
                                                        /* [SdaiString attributeName, 
                                                        SdaiPrimitiveType valueType, 
                                                        void attributeValue,] */ 
                                                        . . . ); /* values */ 
Arguments:

schemaName

Specifies the name of EXPRESS schema that defines the actual instance type to be created. This EXPRESS schema must exist as a dictionary model in the EDMdatabase. Schema names are case insensitive. Schema names are unique in an EDMdatabase.

entityName

Specifies the name of an entity in the schema <schemaName>. The combination of <schemaName> and <entityName> uniquely defines the instance type to create. Entity names are case insensitive.

numberAttr

An integer number that specifies the number of attribute values to put in the operation.

attributeName

For each attribute value to assign the three following arguments in the following order have to be specified:

  1. <attributeName>: Name of the actual attribute. Attribute names are case insensitive. The attribute name must be qualified with the entity name when the attribute name is not unique within the actual entity.
  2. <valueType>: The specified primitive type <valueType> must be the same or a compatible data type of the actual attribute domain as defined in the attribute declaration in the related EXPRESS schema.

    All data types except sdaiAGGR can be handled by this operation. Aggregates cannot be assigned as attribute data value by this operation. Aggregates must be assigned to attributes by either sdaiCreateAggr or sdaiCreateAggrBN operations. The primitive type sdaiSELECT can be used to write all data types. The primitive type sdaiADB can be used to write all data types except typed values.
    The primitive type sdaiINTEGER is compatible with sdaiREAL, and sdaiBOOLEAN is compatible with sdaiLOGICAL, hence conversion between these compatible data types will be performed when required.
    An aggregate, i.e. data type sdaiAGGR is illegal in this operation.
  3. <attributeValue> : The data value to assign to the actual attribute in the specified instance. The type of <attributeValue> must be the same as specified in the <valueType> 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 instId;
SdaiAttr familyNameId, sexId;
...
instId = edmiCreateScratchInstanceAndPutAttrsBN (
"Example_Schema", 
"Person", 
2, 
"FamilyName", sdaiSTRING, "Smith", 
"Sex", sdaiENUMERATION, Male); 
if (! instId) {
/* Error in operation */ 
printf("\nError in edmiCreateScratchInstanceAndPutAttrsBN: %s\n", 
edmiGetErrorText(sdaiErrorQuery())); 
goto error; 
}
...

  • No labels