Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

modelId

A numeric modelID that uniquely identifies the data model in the EDMdatabase to run the specified EDMquery on.
The modelID is returned when the model is created or it can be retrieved by the following operations: edmiGetModel , edmiGetModelBN and sdaiGetInstanceModel

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.
This number should correspond to signature of the actual EDMquery function, i.e., the <arguments> should correspond to the number of formal parameters in the actual EDMquery function declaration in the EDMquerySchema.

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 .
See detailed descriptions of the available options below.

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:

  1. <dataType> : The data type (SdaiPrimitiveType) of the argument. The legal data type of an argument is specified in the signature of the actual EDMquery function.

    Legal data types are:
    sdaiINTEGER, sdaiREAL, sdaiSTRING, sdaiAGGR, sdaiINSTANCE, sdaiBOOLEAN, sdaiLOGICAL, sdaiBINARY, sdaiENUMERATION, sdaiSELECT and edmiINDETERMINATE
  2. <value>: The data value to assign as the actual argument value when invoking the specified EDMquery function. The data value must be of the same primitive type as specified in the <dataType> argument.

...

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;