...
Code Block | ||||
---|---|---|---|---|
| ||||
EdmiError edmiRemoteCreateInstanceAndPutAttrs(SdaiServerContext serverContextId,
SdaiModel remoteModelId,
SdaiEntity entityId,
SdaiInteger attributes,
SdaiAppInstance *newInstanceId,
SdaiInvocationId *edmiInvocationId,
/* [SdaiAttr attributeId, SdaiPrimitiveType valueType, SdaiVoid value] */
...);
|
This operation creates an entity instance in an edmModel in a remote EDMdatabase and in the same operation, optionally puts values into any number of its attributes.
This operation is only applicable on data models.
Related functions: edmiRemoteCreateInstanceAndPutAttrsBN, edmiRemoteCreateInstanceAndPutAttrsBNEx, edmiRemoteCreateInstanceAndPutAttrsEx
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteCreateInstanceAndPutAttrs(SdaiServerContext serverContextId,
SdaiModel remoteModelId,
SdaiEntity entityId,
SdaiInteger attributes,
SdaiAppInstance *newInstanceId,
SdaiInvocationId *edmiInvocationId,
/* [SdaiAttr attributeId, SdaiPrimitiveType valueType, SdaiVoid value] */
...);
Arguments:
Arguments
...
1 | Type | Name | Comment | ||||
2 | SdaiServerContext | serverContextId | Context identification, from edmiDefineServerContext | ||||
3 | SdaiModel | remoteModelId | The numeric modelID that uniquely identifies the edmModel in the remote | _EDMdatabase | _ in which the instance is to be created. | ||
4 | SdaiEntity | entityId | The numeric entityID that uniquely identifies the entity definition instance in the dictionary model within the remote _ EDMdatabase{_}. | ||||
5 | SdaiInteger | attributes | The number of attribute values given in the variable argument list <values>. | ||||
6 | SdaiAppInstance | newInstanceId | Variable that will receive the numeric instanceID that uniquely identifies the created instance in the remote EDMdatabase. | ||||
7 | SdaiInvocationId | edmiInvocationId | Currently not used. | ||||
8 | SdaiAttr | values | For each attribute value to assign, the three following arguments in the following order must be specified: A numeric attributeID that uniquely identifies an attribute definition instance in the remote EDMdatabase . The attributeIDs are returned from the edmiRemoteGetAttrDefinition and edmiRemoteGetAttrDefinitionBN functions. <valueType> : | ||||
9 | SdaiPrimitiveType | The specified primitive type 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 edmiRemoteCreateAggrAndWriteAggrElements or edmiRemoteCreateAggrAndWriteAggrElementsBN operations. The primitive type sdaiSELECT can be used to write any data type. The primitive type sdaiADB can be used to write any data type except typed values. | The primitive type sdaiINTEGER is compatible with sdaiREAL, and sdaiBOOLEAN is compatible with sdaiLOGICAL, hence automatic conversion between these compatible data types will be performed when required. | The data type sdaiAGGR is illegal in this operation. | ||
10 | SdaiVoid | The data value to assign to the attribute in the created instance. The type of <value>must be the same as that specified in the <valueType> argument. |
Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an _EDMinterface_ error code. Use edmiGetErrorText to get the error text corresponding to the error code.
Example:
EdmiError rstat;
SdaiServerContext myContext;
SdaiInstance instId;
SdaiModel modelId;
SdaiEntity entityId;
SdaiAttr nameAttrId, ageAttrId;
SdaiAttr weightAttrId, marriedAttrId;
/* Create Server Context */
rstat =
Return Value
...
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Options
...
Example
...
Code Block | ||
---|---|---|
| ||
EdmiError rstat; SdaiServerContext myContext; SdaiInstance instId; SdaiModel modelId; SdaiEntity entityId; SdaiAttr nameAttrId, ageAttrId; SdaiAttr weightAttrId, marriedAttrId; /* Create Server Context */ rstat = edmiDefineServerContext("MyContext", |
...
"Johnny", "Supervisor", "cf37ftr", |
...
"TCP", "9090", "MyServerHost", |
...
NULL, NULL, NULL, NULL, NULL, &myContext); |
...
...
/* Get the model Id */ |
...
rstat = edmiRemoteGetModelBN(myContext, "DataRepository", |
...
"MySocialNetwork", &modelId, NULL); |
...
...
/* Get the entity Id */ |
...
rstat = edmiRemoteGetEntity(myContext, modelId, |
...
"PERSON", &entityId, NULL); |
...
...
/* Get the attribute Ids */ |
...
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "SocialNetwork", |
...
"Person", "NAME", &nameAttrId, NULL); |
...
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "SocialNetwork", |
...
"Person", "AGE", &ageAttrId, NULL); |
...
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "SocialNetwork", |
...
"Person", "WEIGHT", &weightAttrId, NULL); |
...
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "SocialNetwork", |
...
"Person", "MARRIED", &marriedAttrId, NULL); |
...
...
/* Add lucy to my social network */ |
...
rstat = edmiRemoteCreateInstanceAndPutAttrs(myContext, |
...
modelId, entityId, 4, &instId, NULL, |
...
nameAttrId, sdaiSTRING, "Lucy Schmidt", |
...
ageAttrId, sdaiINTEGER, 32, |
...
weightAttrId, sdaiREAL, 59.5, |
...
marriedAttrId, sdaiBOOLEAN, sdaiFALSE); |
...
. . . |
See also
Filter by label (Content by label) | ||||||
---|---|---|---|---|---|---|
|