...
modelId | A numeric modelID that uniquely identifies the data model in the EDMdatabase to run the specified EDMquery on. |
querySchemaName | Specifies the name of the EDMquerySchema that defines the EDMquery of interest. This query schema must exist in the EDMdatabase. Query schema names are case insensitive. |
queryName | Specifies the name of an EDMquery function that should be invoked. EDMquery names are case insensitive. |
arguments | Number of arguments supplied to the actual EDMquery function. maximum number of arguments is 64 |
options | Specifies the options to be used in the invocation of the EDMquery 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 . |
queryResult | Address of a variable that will receive the result of the operation. The received result will be of data type SdaiQueryResult. |
argument_values | For each arguments the following pair of data must be supplied:
|
...
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:
/*===================================================================
/* Extract of an EDMquerySchema */
QUERY_SCHEMA product_doc_approval FOR PDM_SCHEMA;
GLOBAL
DECLARE exps INSTANCE OF PDM_SCHEMA;
END_GLOBAL;
VIEW_ENTITY product_view_with_ids;
Product : Product;
Product_Id : STRING;
Product_Name : STRING;
Document : Document;
Document_Id : STRING;
Document_Name : STRING;
Document_Type : Document_Type;
Product_Data_Type : STRING;
END_VIEW_ENTITY;
LOCAL
result : SET of product_view_with_ids;
...
END_LOCAL;
QUERY_FUNCTION product_documentation (prod_id , prod_name : STRING)
: SET OF product_view_with_ids;
LOCAL
result : SET of product_view_with_ids;
...
END_LOCAL;
. . .
RETURN(result);
END_QUERY_FUNCTION;
END_QUERY_SCHEMA;
====================================================================*/
EdmiError rstat;
SdaiModel modelId;
SdaiQuery queryId;
SdaiQueryResult qs;
short columnWidth,*columnWidths;
String *columns,*columnLabels;
long i,j,n,numberOfRows,numberOfColumns,numberOfVisibleRows;
long len,*ps,*pd,*columnSortFlags,numberOfVisibleColumns;
char **cp,*cpp;
SdaiColumnDescr **columnDescr;
char *dummy = " ";
SdaiInteger *pint;
SdaiString *pstr;
SdaiLogical *plog;
tSdaiSelect *psel;
SdaiInstance *pinst;
SdaiReal myReal,*preal;
char cell[MAX_SIMPLEID];
. . .
if (rstat = edmiExecuteQueryBN(modelId,
"product_doc_approval",
"product_documentation",
2,
RESULT_AS_TABLE,
&qs,
sdaiSTRING, "PIDaba44889",
sdaiSTRING, "myName")) {
/* Error in operation */
printf("\nError: %s in edmiExecuteQueryBN\n",
edmiGetErrorText(rstat));
goto error;
}
/* Make displayable table */
if(qs->data.type == edmiINDETERMINATE) goto err; /* no data */
numberOfRows = qs->rows;
numberOfColumns = qs->columns;
columns = (char*)MALLOC(numberOfRows*numberOfColumns*sizeof(char));
columnWidths = (short*) MALLOC(numberOfColumns*sizeof(short));
memset(columnWidths,'\0',numberOfColumns*sizeof(short));
columnLabels = (char*) MALLOC(numberOfColumns*sizeof(char));
columnSortFlags = (long*) MALLOC(numberOfColumns*sizeof(long));
columnDescr = (qs->columnDescr);
for(i=0; i < numberOfColumns; ++i){
query_primTypes[i] = (*columnDescr)->datatype;
cpp = (char*) MALLOC(strlen((*columnDescr)->columnName)+1);
strcpy(cpp,(*columnDescr)->columnName);
columnLabels[i] = cpp;
columnWidths[i] = (short) strlen(cpp)+2;
columnSortFlags[i] = QUERY_SORT_NONE;
for(j=0; j<numberOfRows; ++j){
sprintf(Cell,"");
if ((*columnDescr)->pvalueSet[j] == sdaiTRUE) {
switch ((*columnDescr)->datatype) {
case sdaiINTEGER:
pint = (SdaiInteger *) (*columnDescr)->pvalue;
sprintf(Cell,"%12ld ",pint[j]);
break;
case sdaiINSTANCE:
case sdaiAGGR:
pinst = (SdaiInstance *) (*columnDescr)->pvalue;
sprintf(Cell,"%12lu ",pinst[j]);
break;
case sdaiSTRING:
case sdaiENUMERATION:
case sdaiBINARY:
pstr = (SdaiString *) (*columnDescr)->pvalue;
sprintf(Cell,"%s ",pstr[j]);
break;
case sdaiREAL:
preal = (SdaiReal *) (*columnDescr)->pvalue;
ps = (long *) &preal[j];
pd = (long *) &myReal;
COPY_REAL(ps,pd);
sprintf(Cell,"%f",myReal);
break;
case sdaiBOOLEAN:
case sdaiLOGICAL:
plog = (SdaiLogical *) (*columnDescr)->pvalue;
if (plog[j] == sdaiTRUE) {
sprintf(Cell,"TRUE");
} else if (plog[j] == sdaiFALSE) {
sprintf(Cell,"FALSE");
} else {
sprintf(Cell,"UNKNOWN");
}
break;
case sdaiSELECT:
psel = (SdaiSelect) (*columnDescr)->pvalue;
selectValueToCell(&psel[j],Cell);
break;
default:
break;
}
}
len = strlen(Cell);
if(len > 0){
columnWidth = len+1;
cpp = (char*) MALLOC(columnWidth+1);
strcpy(cpp,Cell);
cp = columns+(j*numberOfColumns)+i;
*cp = cpp;
} else {
cp = columns+(j*numberOfColumns)+i;
*cp = dummy;
}
if (len >= columnWidths[i]) columnWidths[i] = len + 1;
}
if(columnWidths[i] > QUERY_MAX_COLUMN_WIDTH)
columnWidths[i] = QUERY_MAX_COLUMN_WIDTH;
++columnDescr;
}