Code Block | ||||
---|---|---|---|---|
| ||||
EdmiError edmiRemoteDeleteAggrValue(SdaiServerContext serverContextId,
SdaiAggr aggrId,
SdaiAggrIndex index,
SdaiOptions options,
SdaiInteger *deletedElements,
SdaiInvocationId *edmiInvocationId,
SdaiPrimitiveType valueType,
...);
|
Deletes the first element, or optionally all elements, with a specified data value, from an aggregate in the
...
remote EDMdatabase. For ARRAY type aggregates, the elements them selves will not be deleted. However, their values will be set to indeterminate. This function is only applicable for
...
persistent aggregates owned by application instances.
...
Arguments
...
Type | Name | Comment |
SdaiServerContext | serverContextId | Context identification, from edmiDefineServerContext |
SdaiAggr | aggrId | A numeric aggregateID that uniquely identifies the aggregate of interest in the remote _EDMdatabase._remote EDMdatabase |
SdaiAggrIndex | index | The index of the element in the aggregate to start reading from. This argument is only applicable for the ordered Array and List aggregates. |
SdaiOptions | options | See description of available options below. |
SdaiInteger | deletedElements | A variable that will receive the number of elements that was deleted from the aggregate. |
SdaiInvocationId | edmiInvocationId | Currently not used. |
SdaiPrimitiveType | valueType | The primitive type of the aggregate element value to delete. |
Options: Descriptions:
Return Value
...
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Options
...
Option | Comment |
DELETE_ALL_ELEMENTS | Delete all elements with the specified value from the aggregate. |
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:
/*
SCHEMA Employees
ENTITY person;
Name : STRING;
Age : INTEGER;
END_ENTITY;
ENTITY Manning;
DivisionStaff : ARRAY [0:4] OF SET OF person;
END_ENTITY;
END_SCHEMA;
*/
#define S_TECHNICAL_DIVISION 2
EdmiError rstat;
SdaiInteger nHits, index;
SdaiServerContext myContext;
SdaiInstance manningId, johnnyId;
SdaiAggr parentAggrId, childAggrId;
SdaiQueryResult qexRes;
/* Create Server Context */
rstat = edmiDefineServerContext("MyContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Get the manningId instance. It is assumed that
there is only one instance type Manning */
index = 0;
nHits = 1;
rstat = edmiRemoteSelectInstances(myContext, "AdminRepository",
"Employees", "Manning", NULL, ONLY_INSTANCE_IDS,
NULL, NULL, NULL, &index, &nHits, &qexRes,
NULL, NULL, NULL, NULL);
manningId = qexRes->instanceIds[0];
edmiFreeQueryResult(qexRes);
/* Get the parent aggregate Id */
rstat = edmiRemoteGetAttrsBN(myContext, manningId, 0, 1, NULL,
"DivisionStaff", sdaiAGGR, &parentAggrId);
/* Get the child aggregate with staff
info for the technical division*/
rstat = edmiRemoteGetAggrElement(myContext, parentAggrId,
0, S_TECHNICAL_DIVISION, sdaiAGGR,
&childAggrId, NULL);
/* Delete johnny from set of
tecnical division employees. */
index = 0;
nHits = 1;
rstat = edmiRemoteSelectInstances(myContext, "AdminRepository",
"Employees", "Person", "(NAME = 'Johnny') AND (AGE = 32)",
ONLY_INSTANCE_IDS, NULL, NULL, NULL,
&index, &nHits, &qexRes, NULL, NULL, NULL, NULL);
johnnyId = qexRes->instanceIds[0];
edmiFreeQueryResult(qexRes);
/* Delete Johnny from the aggregate of
employees in the technical division */
rstat = edmiRemoteDeleteAggrValue(myContext,
childAggrId, 0, DELETE_ALL_ELEMENTS,
&nHits, NULL, sdaiINSTANCE, johnnyId);
if (nHits) {
printf("\nJohnny is no longer an employee!");
} else {
printf("\nWarning! Could not find Johnny");
}
. . .
Example
...
Code Block | ||
---|---|---|
| ||
/*
SCHEMA Employees
ENTITY person;
Name : STRING;
Age : INTEGER;
END_ENTITY;
ENTITY Manning;
DivisionStaff : ARRAY [0:4] OF SET OF person;
END_ENTITY;
END_SCHEMA;
*/
#define S_TECHNICAL_DIVISION 2
EdmiError rstat;
SdaiInteger nHits, index;
SdaiServerContext myContext;
SdaiInstance manningId, johnnyId;
SdaiAggr parentAggrId, childAggrId;
SdaiQueryResult qexRes;
/* Create Server Context */
rstat = edmiDefineServerContext("MyContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Get the manningId instance. It is assumed that
there is only one instance type Manning */
index = 0;
nHits = 1;
rstat = edmiRemoteSelectInstances(myContext, "AdminRepository",
"Employees", "Manning", NULL, ONLY_INSTANCE_IDS,
NULL, NULL, NULL, &index, &nHits, &qexRes,
NULL, NULL, NULL, NULL);
manningId = qexRes->instanceIds[0];
edmiFreeQueryResult(qexRes);
/* Get the parent aggregate Id */
rstat = edmiRemoteGetAttrsBN(myContext, manningId, 0, 1, NULL,
"DivisionStaff", sdaiAGGR, &parentAggrId);
/* Get the child aggregate with staff
info for the technical division*/
rstat = edmiRemoteGetAggrElement(myContext, parentAggrId,
0, S_TECHNICAL_DIVISION, sdaiAGGR,
&childAggrId, NULL);
/* Delete johnny from set of
tecnical division employees. */
index = 0;
nHits = 1;
rstat = edmiRemoteSelectInstances(myContext, "AdminRepository",
"Employees", "Person", "(NAME = 'Johnny') AND (AGE = 32)",
ONLY_INSTANCE_IDS, NULL, NULL, NULL,
&index, &nHits, &qexRes, NULL, NULL, NULL, NULL);
johnnyId = qexRes->instanceIds[0];
edmiFreeQueryResult(qexRes);
/* Delete Johnny from the aggregate of
employees in the technical division */
rstat = edmiRemoteDeleteAggrValue(myContext,
childAggrId, 0, DELETE_ALL_ELEMENTS,
&nHits, NULL, sdaiINSTANCE, johnnyId);
if (nHits) {
printf("\nJohnny is no longer an employee!");
} else {
printf("\nWarning! Could not find Johnny");
}
. . . |
See also
Filter by label (Content by label) | ||||||
---|---|---|---|---|---|---|
|