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 »


 
Assigns values to one or more of the attributes of a specified instance. This operation is applicable only to Explicit attributes, not to Inverse or Derive attributes. The attributes are identified by their attributeIds.
Related functions: edmiRemotePutAttrs, edmiRemotePutAttrsBN, edmiRemotePutAttrsBNEx
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemotePutAttrsEx(SdaiServerContext serverContextId,
                                SdaiAppInstance   instance, 
                                SdaiInteger       attributes, 
                                SdaiAttr          attributeIds[],
                                SdaiSelect        attributeValues[], 
                                SdaiOptions       options, 
                                SdaiInvocationId  *edmiInvocationId);  
 
Arguments:

serverContextId

Context identification, from edmiDefineServerContext

instance

A numeric instanceID that uniquely identifies an instance in the remote _EDMdatabase{_}.

attributes

The number of attributes for which to assign values.

attributeIds[]

A buffer of attributeIds. Each attributeId identify an attribute of the given instance for which a value is to be asigned.

attributeValues[]

A buffer of tSdaiSelect structures. Each structure must contain the value to assign to the corresponding attribute.

options

Currently not used.

edmiInvocationId

Currently not used.

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:
#define S_NAT 0
#define S_PHONE 1
#define S_NATTR 2
int i;
EdmiError rstat;
SdaiServerContext myContext;
SdaiInteger index, nHits;
SdaiAttr attrIds[S_NATTR];
tSdaiSelect sel[S_NATTR];
SdaiSelect attrVals[S_NATTR] = {&sel[S_NAT], &sel[S_PHONE]};
SdaiQueryResult qexRes; 
 
/* Create Server Context */ 
rstat = edmiDefineServerContext("MyContext",
"Johnny", "Supervisor", "cf37ftr", 
"TCP", "9090", "MyServerHost", 
NULL, NULL, NULL, NULL, NULL, &myContext); 
 
/* Get the persons nationality attribute ID */
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "MySocialRelations",
"Person", "NATIONALITY", &attrIds[S_NAT], NULL); 
 
/* And his phone number attribute ID */
rstat = edmiRemoteGetAttrDefinitionBN(myContext, "MySocialRelations",
"Person", "PHONE_NO", &attrIds[S_PHONE], NULL); 
 
/* Select all person instances */ 
rstat = edmiRemoteSelectInstances(myContext, "MyRepository", 
"MySocialRelations", "Person", 
NULL, ONLY_INSTANCE_IDS, NULL, NULL, NULL, 
&index, &nHits, &qexRes, NULL, NULL, NULL, NULL); 
 
/* Get nationality and phone number */
for (i=0;i<nHits;i++) {
char _phoneNumber[12];
rstat = edmiRemoteGetAttrsEx(myContext, 
qexRes->instanceIds[i], 0, S_NATTR,  
attrIds, &attrVals[0], GET_ATTRS, NULL); 
 
/* Set correct nationality code */ 
if (! strcmp(attrVals[S_NAT]->value.enumVal, "NOR")) { 
strcpy(_phoneNumber, "+47-"); 
} else if (! strcmp(attrVals[S_NAT]->value.enumVal, "SWE")) { 
strcpy(_phoneNumber, "+44-"); 
} else if (! strcmp(attrVals[S_NAT]->value.enumVal, "DEN")) { 
strcpy(_phoneNumber, "+45-"); 
} else { 
strcpy(_phoneNumber, "+??-"); 

 
/* Concatenate the original phone number */ 
strcat(_phoneNumber, attrVals[S_PHONE]->value.stringVal); 
 
/* Free allocated strings in the 
select buffers */ 
edmiFree(attrVals[S_NAT]->value.enumVal); 
edmiFree(attrVals[S_PHONE]->value.stringVal); 
 
/* Put back the extended phone number */ 
attrVals[S_PHONE]->value.stringVal = _phoneNumber; 
rstat = edmiRemotePutAttrsEx(myContext, qexRes->instanceIds[i], 1,  
&attrIds[S_PHONE], &attrVals[S_PHONE], 0, NULL); 
}
edmiFreeQueryResult(qexRes);
. . .

  • No labels