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 »

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 persistant aggregates owned by application instances.
Related functions:
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteDeleteAggrValue(SdaiServerContext  serverContextId,                                    SdaiAggr           aggrId,                                    SdaiAggrIndex      index,                                    SdaiOptions        options,                                    SdaiInteger        *deletedElements,                                    SdaiInvocationId   *edmiInvocationId,                                    SdaiPrimitiveType  valueType,                                      ...);
 
Arguments:

serverContextId

Context identification, from edmiDefineServerContext

aggrId

A numeric aggregateID that uniquely identifies the aggregate of interest in the remote _EDMdatabase._

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.

options

See description of available options below.
Options may be joined by using the bitwise OR operator. Default behaviour is that only the first obtained matching element will be deleted.

deletedElements

A variable that will receive the number of elements that was deleted from the aggregate.

edmiInvocationId

Currently not used.

valueType

The primitive type of the aggregate element value to delete.

Options: Descriptions:

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"); 
}
. . .

  • No labels