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 Next »


 
Search in the specified model for instances of the specified type that match the specified condition. Optionally all subtype instances of the specified type will be search as well.
The condition is specified as any legal symbolic Express-X logical expression. All instances of the specified type in the specified model will match an empty condition, i.e. the <condition> argument set to NULL.
Each matching instance is identified by a numeric instanceID that uniquely identifies an instance in the EDMdatabase All possible matching instances will be collected in a temporarily aggregate, hence this aggregate will be queried for matching instances. The index of the first aggregate element to test for an instance that match the specified condition, and the maximum number of matching instances to return, are specified as input arguments to the function. The actual number of matching instances returned and the "index of the last returned matching instance in the aggregate" are returned from the operation. This makes it convenient to query the aggregate by the edmiSelectInstancesBN function in an incremental way.
The <condition> argument will be compiled by the EDMexpressXCompiler. The specified query will fully be executed by the EDMexpressVM.
The actual model to query must be open before this operation can be successfully performed.
When the input arguments <maxBufferSize> == 0 & <resultBuffer> == NULL no instanceId or elementNumber will be returned. Only the number of matching instances/elements will be returned. The total number of hits will be returned in the <numberOfHits> argument. The argument <index> is not updated.
Related functions: edmiFindInstancesBN ,edmiFindAggrInstances, edmiFindAggrInstancesBN, edmiQuery
Header:
#include "sdai.h"
Prototype:
EdmiError edmiSelectInstancesBN(SdaiModel    modelId,
                                 SdaiString   entityName, 
                                 SdaiString   condition, 
                                 SdaiInteger  options, 
                                 SdaiInteger  maxBufferSize, 
                                 SdaiInteger  *index, 
                                 SdaiInteger  *numberOfHits, 
                                 SdaiInstance *resultBuffer); 
Arguments:

modelId

A numeric modelID that uniquely identifies the data model of interest in the EDMdatabase .
The modelID is returned from the functions: sdaiCreateModel , sdaiCreateModelBN , sdaiOpenModelBN , edmiGetModel , edmiGetModelBN , sdaiGetInstanceModel

entityName

Specifies the name of the entity that defines the actual instance type to query. Entity names are case insensitive.

condition

Specifies the condition the target instances should match. All instances in the specified aggregate match an empty condition, i.e., <condition> = NULL.
All legal symbolic Express-X logical expressions are a legal <condition> value. This <condition> argument will be compiled by the EDMexpressXCompiler

options

Specifies the options to be used in the invocation of the edmiSelectInstancesBN function. The <condition> value can be specified as a bitwise OR between the actual options to enable. All option names are defined on the header file sdai.h .
See detailed descriptions of the available options below.

maxBufferSize

Specifies the size (in number of bytes) of the buffer to receive the instanceID of the matching instances. The actual number of returned matching instances will never be greater than the number of instanceID that can be placed in a buffer of the size specified by this argument.

index

In: The index of the aggregate element to start searching at. The index of the first element in the actual aggregate will always be index zero, independent of the aggregate type. Hence the legal index range is: 0<= index < number of elements in the aggregate.
Out: The index of the "last returned matching element". This argument enables the caller to search for instances in an incremental way by specifying this returned "index value plus one" as the input to the next edmiSelectInstancesBN function and so on.

numberOfHits

In: Specifies the maximum number of matching instances to return. If this number is greater than the limitation specified by the <maxBufferSize> argument, then the maximum number of hits will be calculated from the <maxBufferSize> argument.
Out: The number of found matching instances.

resultBuffer

Address of a buffer in the calling application that will receive the instanceID of each returned matching instance. This buffer is mapped to a SdaiInstance array when the instanceID of each returned matching instance is stored. The <maxBufferSize> argument should prevent the function to write past buffer.

Option Description

SUBTYPES

Specifies that in addition to all instances of the type specified by the <entityName> argument, all subtype instances of the specified type should be queried as well.

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
SdaiModel modelId;
SdaiInteger index, numberOfHits;
int i;
SdaiInstance resultBuffer[MAX_ELEMENTS];
. . .
index = 0;
numberOfHits = MAX_ELEMENTS;
if (rstat = edmiSelectInstancesBN(
modelId, 
"Person", 
"(Exists(children)) AND  
(SizeOf(Query(c <* children | c.sex = MALE)) > 2)", 
SUBTYPES, 
sizeof(resultBuffer), 
&index, 
&numberOfHits, 
resultBuffer)) { 
/* Error in operation */ 
printf("\nError: %s in edmiSelectInstancesBN\n", 
edmiGetErrorText(rstat)); 
goto error; 
}
/* Print instanceId of matching instances */
for (i = 0; i < numberOfHits; i++) {
printf("\ninstanceId: %lu", resultBuffer[i]); 
}
...

  • No labels