c怎么调用查询构建器

int   
	n_entries = 1, 
	n_found = 0,
	n_contents = 0;
tag_t 
	query = NULLTAG, 
	items = NULLTAG,
	*item_tags = NULL;
char
	**entries = NULL, 
	**values = NULL;
QRY_find("Item...", &query);
entries = (char **) MEM_alloc(1 * sizeof(char *));
entries[0] = (char *)MEM_alloc(strlen("ItemID") + 1);
strcpy(entries[0], "ItemID");
values  = (char **) MEM_alloc(1 * sizeof(char *));
values[0] = (char *)MEM_alloc( strlen(item_id) + 1);
QRY_execute(query, n_entries, entries, values, &n_found, &item_tags);

int query_oprevision_tags(char* query_value,logical is_gyxz,vector<tag_t> &oprevision_tags)
{
	int   
		n_entries = 1, 
		n_found = 0,
		n_contents = 0;
	tag_t 
		query = NULLTAG, 
		items = NULLTAG,
		*item_tags = NULL;
	char
		**entries = NULL, 
		**values = NULL;

	 int num_clauses=0;
	 char**  attr_names;
	 char** entry_names;
	 char** logical_ops;
	 char** math_ops;
	 char** default_values;
	 tag_t *lov_tags;
	 int* attr_types;

	
	ITKCALL(QRY_find("0__find_oprevision", &query));
	entries = (char **) MEM_alloc(1 * sizeof(char *));
	values  = (char **) MEM_alloc(1 * sizeof(char *));
	
	values[0] = (char *)MEM_alloc(strlen(query_value) + 1);
	strcpy(values[0],query_value);
	if(query != NULLTAG){
		ITKCALL(QRY_describe_query(query,&num_clauses,&attr_names,&entry_names,&logical_ops,&math_ops,&default_values,&lov_tags,&attr_types));
		for(int n=0;n<num_clauses;n++)
		{
			if(strcmp(attr_names[n], "c8_gyxz_no") == 0 && is_gyxz){
				entries[0] = (char *)MEM_alloc(strlen("c8_gyxz_no") + 1);
				strcpy(entries[0], entry_names[n]);
			} else if (strcmp(attr_names[n], "c8_common_no") == 0 && (!is_gyxz)){
				entries[0] = (char *)MEM_alloc(strlen("c8_common_no") + 1);
				strcpy(entries[0], entry_names[n]);
			}
		}
		WriteLog( "Query is Exist!\n");
		ITKCALL(QRY_execute(query, n_entries, entries, values, &n_found, &item_tags));

		DOFREE(attr_names);
		DOFREE(entry_names);
		DOFREE(logical_ops);
		DOFREE(math_ops);
		DOFREE(default_values);
		DOFREE(lov_tags);
		DOFREE(attr_types);

	}else{
		WriteLog( "Query is NULL \n");
	}
	if (n_found>0)
	{
		WriteLog( "查找到了工序版本对象\n");
		for(int i=0;i<n_found;i++){
			oprevision_tags.push_back(item_tags[i]);
		}
	}else{
		WriteLog( "没有查找到工序版本对象\n");
	}

	DOFREE(item_tags);

	return ITK_ok;
}

  

上一篇:emlog博客程序几行代码统计网站在线人数


下一篇:Map常用遍历方法