edmiRemoteExecuteQuery
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] */ ...);
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.
Arguments
1 | Type | Name | Comment |
2 | Â SdaiServerContext | serverContextId | Context identification, from edmiDefineServerContext |
3 | Â SdaiString | 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. |
4 | Â SdaiString | 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. |
5 | Â SdaiString | remoteQuerySchemaName | The name of the EDMquerySchema in which the Query function to be run is defined. Query Schema names are case insensitive. |
6 | Â SdaiString | remoteQueryName | The name of the Query function to be run. Query Schema names are case insensitive. |
7 | Â SdaiInteger | nFileMappings | Currently not used. |
8 | Â SdaiFileMapping | fileMapping[] | Currently not used. |
9 |  SdaiInteger | options | See description of available options below. Options may be joined by using the bitwise OR operator. |
10 | Â SdaiQueryResult | queryResult | A variable that will receive the address of a locally allocated tSdaiQueryResult data structure. See the header file sdai.h for a description. |
11 | Â SdaiString | remoteXmlConfigName | The name of the defined XML configuration to apply on the XML formatted output from the Query function. |
12 | Â SdaiString | 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]. |
13 | Â SdaiInvocationId | edmiInvocationId | Currently not used. |
14 | Â SdaiInteger | 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. |
15 | Â | parameterDataType | The data type of the succeeding argument <parameterValue>. This argument may only take one of the following values: |
16 | Â | parameterValue | The value of the parameter. The arguments <parameterDataType> and <parameterValue> must be supplied in pairs for each of the <numberOfParameters> parameters. |
Return Value
Â
Options
Option | Comment |
ALL_ATTRIBUTES | When the argument <attributes> is NULL or an empty string, all attributes of the instances will be included in the query result. However, if the <attributes> argument is used to add one or more additional constructed columns or to rename a column in the query result, the return of all the instance attributes will be hindered due to an <attributes> argument that is no longer NULL or an empty string. Use this option to force the including of all instance attributes even when the <attributes> argument is not NULL or an empty string. This option is only applicable on aggregates of instances. |
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. [RESULT_AS_TABLE] must be activated when [RESULT_IN_FILE] is used with [HTML_FORMAT] or [ASCII_FORMAT]. |
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. The number of elements in the aggregate will be the number of rows in the table and the number of attributes in the actual instance type or view type will be the number of columns in the table. |
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 well formed 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. 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. |
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); . . .
Â
See also
Filter by label
There are no items with the selected labels at this time.
Â