edmiRemoteGetInstanceReferences

EdmiError edmiRemoteGetInstanceReferences(SdaiServerContext serverContextId,
                                            SdaiInstance      currInst,
                                            SdaiVersion       version, 
                                            SdaiInteger       index,
                                            SdaiInteger       *numberOfRefs,
                                            SdaiInstance      *resultBuffer,
                                            SdaiInvocationId  *edmiInvocationId);
  

Returns a buffer containing the instanceIds of all instances that refer to the specified instance at least once. The number of references from each instance may not be found by this function. Instances that only refer to the given instance through their derived or inverse attributes will not be returned. I.e only the instances with references from explicit attributes will be included in the returned instance buffer. For each application instance in an edmModel the system automatically maintains a reference aggregate containing the instanceIds of all the instances that externally refers to it. Hence, these externally referring instances, which of course may be of any instance type, will allways be available in the instances reference aggregate. It is the contents of this reference aggregate that will be returned in a buffer from this function. Note that if the edmModel was created with the option NO_INSTANCE_REFERENCES, no instance reference aggregate will be maintained. The advantage of this is that data manipulation performance improves for the edmModel. On the other hand, the drawback is that this function will return an error code.

The index of the first instance reference aggregate element to read, and the maximum number of instances to return, are specified as input arguments to the function. The actual number of instances read will be returned from the function. This makes it possible to query through huge amounts of instances by means of a loop where each iteration handles a small subset of the total instance reference aggregate.

 

Arguments


TypeNameComment

SdaiServerContext

serverContextId

Context identification, from edmiDefineServerContext

SdaiInstance

currInst

The instanceID that uniquely identifies the instance in the remote  EDMdatabase  for which to return a buffer with the instanceIds of all instances that refers to it.

SdaiVersion

version

The version of the edmModel to apply this function call on. The <version> parameter is a numeric sequence number counting from one by increments of one for each new model version that is created. A zero model version number means the current version.

SdaiInteger

index

The instance reference aggregate index to start reading from.

SdaiInteger

numberOfRefs
  • In-value: The maximum number of instances to return in the <resultBuffer> argument. This value must be less or equal to the maximum number of instanceIDs that can be contained in the <resultBuffer>. Otherwise, writing outside the buffer may result.
  • Out-value: The actual number of instances returned in the <resultBuffer>. This value will always less or equal to its in-value.

SdaiInstance

resultBuffer

Address of a buffer in the calling application that will receive the instanceIds contained in the instance reference aggregate.

SdaiInvocationId

edmiInvocationId

Currently not used.

Return Value


Error rendering macro 'excerpt-include' : User 'null' does not have permission to view the page 'US:_r_EDMInterface'.

 

Options


  

 

Example


 

 #define S_BATCHSIZE 10
 int i;
 EdmiError rstat;
 SdaiServerContext myContext;
 SdaiInteger index, nHits;
 SdaiQueryResult qexRes;
 SdaiInstance personId;
 SdaiInstance refBuff[S_BATCHSIZE];
  
 /* Create Server Context */
 rstat = edmiDefineServerContext("MyContext",
 "Johnny", "Supervisor", "cf37ftr", 
 "TCP", "9090", "MyServerHost", 
 NULL, NULL, NULL, NULL, NULL, &myContext); 
  
 /* Get a persons instance Id from a unique
 primary key attribute 'PID' */ 
 nHits = 1;
 index = 0;
 rstat = edmiRemoteSelectInstances(myContext,
 "DataRepository", "SocialRelations", 
 "Person", "PID = '16126353127'", 
 (ONLY_INSTANCE_IDS | SUBTYPES), 
 NULL, NULL, NULL,  
 &index, &nHits, &qexRes, 
 NULL, NULL, NULL, NULL); 
 if (!nHits) {
 printf("\nRequested pid not found."); 
 goto err; 
 }
 personId = qexRes->instanceIds[0];
  
 /* Get all external references to the person.
 Read them in batches of S_BATCHSIZE */ 
 nHits = S_BATCHSIZE; 
 while (nHits == S_BATCHSIZE) {
 nHits = S_BATCHSIZE; 
 rstat = edmiRemoteGetInstanceReferences(myContext,  
 personId, 0, index, &nHits, &refBuff[0], NULL); 
 for (i=0;i<nHits;i++) {
 printf("\n%4d - Referencing Id = %d", (index+i), refBuff[i]);
 } 
 index += nHits; 
 }
 . . .

 

See also

Filter by label

There are no items with the selected labels at this time.

Â