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 »


 
Implements the Express Query operation as defined in section 12.6.7 Query expression in ISO 10303-11:1994(E) : The EXPRESS Language Reference Manual.
The data model that hosts the source aggregate of the operation must be open before this operation can be successfully performed.
The edmiQuery operation is fully processed by the EDMexpressVM.
Related functions: edmiSelectInstancesBN
Header:
#include "sdai.h"
Prototype:
EdmiError edmiQuery(SdaiAggr           sourceAggr,
                     SdaiString         condition,  
                     SdaiInteger        options, 
                     SdaiInteger        *membersInResult, 
                     SdaiPrimitiveType  *elementType, 
                     SdaiBoolean        **elementsValueSet, 
                     void               *result);  
Arguments:

sourceAggr

A numeric aggregateID that uniquely identifies the source aggregate to be queried.
The aggregateID is returned when the aggregate is created or it can be retrieved with an EDMinterface get operation.

condition

Any legal symbolic Express-X logical expression. This <condition> argument will be compiled by the EDMexpressXCompiler

options

Specifies the options to be used in the invocation of the edmiQuery function. The <options> 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.

membersInResult

Address of a SdaiInteger variable that will receive the returned number of elements in the result data set.

elementType

Address of a SdaiPrimitiveType variable that will receive the primitive type of the resulting data set.

elementsValueSet

Address of a SdaiBoolean array. The index range of this array is:
0 <= index < membersInResult
An element value = sdaiTRUE means that the corresponding element in the result data set is set (is valid).
This argument is only valid when the <sourceAggr> is an ARRAY.
This virtual memory occupied by the <elementsValueSet> argument should be released by the calling application, using the EDMinterface operation edmiFree when the data is no longer needed by the application.

result

Address of a void* variable that will receive the resulting data set. The data type and value of the resulting data set is dependent of the <options> argument.

Option Description

AS_SCRATCH_AGGR

The result of the operation will be returned in a new created scratch aggregate. The aggregate type is dependent of the aggregate type of the source aggregate <sourceAggr>, and will be according to the definition of the operation in the EXPRESS language.
A numeric aggregateID that uniquely identifies the resulting scratch aggregate instance will be returned in the <result> argument.
AS_SCRATCH_AGGR is the default value of the <options> argument.

AS_MEMORY_BUFFER

The operation result aggregate will be returned as a memory buffer in the calling application's virtual memory. The memory address (byte address) of the memory buffer will be returned in the <result> argument.
The memory buffer will be an array of the <elementType> data type, i.e., an array of SdaiInteger, SdaiReal, SdaiString, SdaiInstance, SdaiAggr, SdaiBoolean, SdaiLogical, SdaiBinary, SdaiEnumeration or SdaiSelect.
The virtual memory in the calling application's memory will be allocated by EDMinterface. This virtual memory should be released by the calling application, using the EDMinterface operation edmiFree when the data is no longer needed by the application.

IN_OPERAND1

The result of the operation will be in the aggregate specified in the <sourceAggr> argument. Hence the original value in the <sourceAggr> aggregate will be overwritten by the operation.

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
EdmiError rstat;
SdaiAggr sourceAggr;
SdaiInteger membersInResult;
SdaiPrimitiveType elementType;
SdaiBoolean *elementsValueSet;
SdaiInstance *p, *result;
int i;
. . .
if (rstat = edmiQuery(sourceAggr,
"Exists(Father) AND (SizeOf(Mother.children) > 2)", 
AS_MEMORY_BUFFER,
&membersInResult,
&elementType, 
&elementsValueSet, 
(void *) &result)) { 
/* Error in operation */ 
printf("\nError: %s in edmiQuery\n", 
edmiGetErrorText(rstat)); 
goto error; 
}
/* Print out the returned instanceIds */
p = result;
for (i = 0; i < membersInResult; i++) {
printf("\nInstanceID: %10lu",*p);
++p; 
}
edmiFree(result);
. . .

  • No labels