Invokes the EDMexpressVM with an EDMquery (also denoted Query Functions) and a list of corresponding input parameters on a data model within a remote _EDMdatabase_ .
Query functions are defined in EDMquerySchemas. EDMquerySchemas must be compiled to extend the dictionary model of a data model with one or more Query functions. The function edmiRemoteDefineSchema may be used to compile an EDMquerySchema in a remote EDMdatabase.
The memory needed for the returned result of an EDMquery will be implicitly allocated by this function. The result will be returned in an tSdaiQueryResult data structure. See the header file sdai.h for a description of this data structure. Use the function edmiFreeQueryResult to release the locally allocated memory when it is no longer needed.
The interactive EDMdebugger within the EDMsupervisor may be used to test and debug any Express or Express-X schemata, including Query functions, executed by the EDMexpressVM.
The "expressions logging" feature of EDM offers powerful tracing capabilities for testing and debugging Query functions. Use edmiDefineExpressionsLog to configure this feature.
Related functions: edmiRemoteExecuteQueryEx
Prototype:
EdmiError edmiRemoteExecuteQuery(SdaiServerContext serverContextId,
SdaiString remoteRepositoryName,
SdaiString remoteModelName,
SdaiString remoteQuerySchemaName,
SdaiString remoteQueryName,
SdaiInteger nFileMappings,
SdaiFileMapping fileMapping[],
SdaiInteger options,
SdaiQueryResult *queryResult,
SdaiString remoteXmlConfigName,
SdaiString resultFileName,
SdaiInvocationId *edmiInvocationId,
SdaiInteger numberOfParameters,
/* For each query parameter:[SdaiPrimitiveType parameterDataType,parametervalue] */
...);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
remoteRepositoryName |
The name of the repository in the remote _EDMdatabase_ that contains the model for which the Query function is to be run. Repository names are case sensitive. |
remoteModelName |
The name of the model on which to run the query. Model names are case sensitive. The combination of the <remoteRepositoryName> and <remoteModelName> arguments uniquely identifies a model in a remote _EDMdatabase{_}. |
remoteQuerySchemaName |
The name of the EDMquerySchema in which the Query function to be run is defined. Query Schema names are case insensitive. |
remoteQueryName |
The name of the Query function to be run. Query Schema names are case insensitive. |
nFileMappings |
Currently not used. |
fileMapping[] |
Currently not used. |
options |
See description of available options below. |
queryResult |
A variable that will receive the address of a locally allocated tSdaiQueryResult data structure. See the header file sdai.h for a description. |
remoteXmlConfigName |
The name of the defined XML configuration to apply on the XML formatted output from the Query function. |
resultFileName |
The name of the file on the local file system that will receive the XML formatted output from the Query function. This option has no effect unless combined with the option [RESULT_IN_FILE]. |
edmiInvocationId |
Currently not used. |
numberOfParameters |
The number of parameters that will be supplied to the Query function in the variable argument list of this function. For each parameter, a <parameterDataType> and a <parameterValue> argument must be supplied. |
parameterDataType |
The data type of the succeeding argument <parameterValue>. This argument may only take one of the following values: |
parameterValue |
The value of the parameter. |
Options: Descriptions:
ALL_ATTRIBUTES |
|
INCLUDE_CONFIGURATION |
Includes the XML Configuration in the generated ISO10303-28 compliant XML formatted query result. This option has no effect unless combined with the options [XML_FORMAT] and [RESULT_IN_FILE]. |
INCLUDE_SCHEMA |
Includes the underlying meta data in the generated ISO10303-28 compliant XML formatted query result. This option has no effect unless combined with the options [XML_FORMAT] and [RESULT_IN_FILE]. |
RESULT_IN_STRING |
The resulting table will be returned in a string allocated in heap-memory of the calling application. Use edmiFree to release allocated memory. Use the option [RESULT_IN_FILE] to write the table to a file. |
OPEN_MODEL_FOR_WRITE_ACCESS |
The model will be opened for write access. This enables manipulation of the model population from query functions. |
EXTRACT_SHALLOW |
Use this option to force a shallow XML formatted query result. ISO10303-28 compliant XML Query results are deep by default. No other query result format supported by this function is deep. Hence, this option has no effect unless combined with the option [XML_FORMAT]. |
RESULT_AS_ID |
The query result will be returned as an aggregateID when sdaiAGGR is the declared data type of the return value from the Query function. The aggregateID will be returned in the element data.value.aggrValof the returned tSdaiQueryResult data structure. |
RESULT_AS_ID_CONTENTS |
The query result will be returned as a table when sdaiAGGR is the declared data type of the return value from the Query function. The table will consist of a single column with one row for each element in the returned aggregate. |
RESULT_IN_FILE |
The resulting table will be written to a file on the local file system of the calling application. The name of the file must be specified in the <resultFileName> argument. |
EDM_IDENTIFIERS |
The instanceIds that uniquely identify the instances in the remote EDMdatabase will be used as xmlIds for identification of the instances within the ISO10303-28 compliant XML formatted query result. |
RESULT_AS_TABLE |
The query result will be returned as a table. This option is only applicable for Query functions that return an aggregate of either instances or view instances. |
HTML_FORMAT |
The query result table will be presented in HTML format in a locally allocated string or in a file on the local file system. See the options [RESULT_IN_FILE] and [RESULT_IN_STRING]. |
ASCII_FORMAT |
The query result table will be presented in plain ASCII format in a locally allocated string or in a file on the local file system. See the options [RESULT_IN_FILE] and [RESULT_IN_STRING]. |
OLD_XML_FORMAT |
The result of the query will be returned in a simple wellformed XML formatted file on the local file system. |
XML_FORMAT |
The result of the query will be returned in an ISO10303-28 compliant XML formatted string or in a file on the local file system. |
ZIPPED_FILE |
The file given by the argument <resultFileName> will be compressed with gzip. This option has no effect unless combined with the option [RESULT_IN_FILE]. |
IGNORE_EMPTY_COLUMNS |
Columns for attributes that do not have defined values for any of the returned instances will be left out of the query result table. |
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:
/*
– --------------------------------------
– File: c:/data/furniture.exp
– --------------------------------------
SCHEMA Furniture
TYPE tScrewType = ENUMERATION OF (PHILIPS, ALLEN, FLAT); END_TYPE;
ENTITY Screw;
ID : STRING;
TYPE : tScrewType;
LEN : REAL;
DIA : REAL;
END_ENTITY;
ENTITY Dining_Table;
Name : STRING;
Legs : INTEGER;
Length : REAL;
Width : REAL;
Height : REAL;
Screws : BAG OF Screw;
END_ENTITY;
END_SCHEMA;
– ---------------------------------------
– File: c:/data/furniture_query.qex
– ---------------------------------------
QUERY_SCHEMA Furniture_Query FOR Furniture;
GLOBAL
DECLARE src INSTANCE OF Furniture;
END_GLOBAL;
VIEW_ENTITY View_Table;
Name : STRING;
Area : REAL;
END_VIEW_ENTITY;
QUERY_FUNCTION Dining_Table_Area (Area : REAL) : SET OF View_Table;
LOCAL
result : SET of View_Table;
currView : View_Table;
table_area : REAL;
END_LOCAL;
FROM(sdt:src::Dining_Table)
WHEN TRUE;
BEGIN
table_area := sdt.Length*sdt.Width;
IF(table_area > Area ) THEN
NEW currView;
currView.Name := sdt.Name;
currView.Area := table_area;
result ++ currView;
END_IF;
END;
RETURN(result);
END_QUERY_FUNCTION;
END_QUERY_SCHEMA;
*/
int i, j;
EdmiError rstat, error;
SdaiInteger nErr, nWrn;
SdaiServerContext myContext;
SdaiQueryResult qexRes;
/* Define Remote Server Context */
rstat = edmiDefineServerContext("MyRemoteServerContext",
"Johnny", "Supervisor", "cf37ftr",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &myContext);
/* Compile the Express Schema */
rstat = edmiRemoteDefineSchema(myContext, EXPRESS_SCHEMA_TYPE,
"c:/data/furniture.exp", "c:/temp/furniture.dia",
"Furniture", 0, &nWrn, &nErr, NULL);
/* Compile the Query Schema */
rstat = edmiRemoteDefineSchema(myContext, QUERY_SCHEMA_TYPE,
"c:/data/furniture_query.qex", "c:/temp/furniture_query.dia",
"Furniture_Query", 0, &nWrn, &nErr, NULL);
/* Import the product catalogue from a p21 file
into the model Products in the DataRepository */
rstat = edmiRemoteReadStepFile(myContext, "DataRepository",
"Products", NULL, NULL, "c:/data/furniture.stp",
"c:/temp/furniture.stp.dia", "Furniture", NULL,
0, &nWrn, &nErr, &error, NULL);
/* Get all dining tables with an area
greater than 2.0 square meters */
rstat = edmiRemoteExecuteQuery(myContext, "DataRepository",
"Products", "Furniture_Query", "Dining_Table_Area",
0, NULL, RESULT_AS_TABLE | RESULT_AS_ID_CONTENTS,
&qexRes, NULL, NULL, NULL, 1, sdaiREAL, 2.0);
/* Print all matching dining tables */
printf("\nThe following dining tables was found");
for (i=0; i<qexRes->rows; i++) {
for (j=0; j<qexRes->columns; j++) {
SdaiString _name;
SdaiReal _area;
if(qexRes->columnDescr[j]->datatype == sdaiSTRING) {
_name = ((SdaiString*) qexRes->columnDescr[j]->pvalue)[i];
} else {
_area = ((SdaiReal *) qexRes->columnDescr[j]->pvalue)[i];
}
printf("\n%s - %f m2", _name, _area);
}
}
edmiFreeQueryResult(qexRes);
. . .