作用:
此函数可以让用户在一个初始化的请求句柄上添加数据排序逻辑,通常用在JDB_Select之前。
语法:
JDEDB_RESULT JDB_SetSequencing(HREQUEST hRequest, LPSORT lpSort, uShort nNum, JDEDB_SET nSet);
参数表:
参数
|
说明
|
用法
|
hRequest
|
请求句柄
|
|
lpSort
|
排序结构指针
|
|
nNum
|
排序数量
|
|
nSet
|
替换或追加现有的字符串
|
|
返回值:
返回值
|
说明
|
JDEDB_PASSED
|
操作成功
|
JDEDB_FAILED
|
操作失败
|
事例/* Declare variables associated with JDB_SetSequencing */
HREQUEST hRequest = NULL;
LPSORT lpSort = NULL;
int nNumSort =2;
/* Allocate memory by calling the JDE memory allocation routine */
lpSort = jdeAllocReturnIfError(COMMON_POOL, nNumSort * size of(SORTSTRUCT), MEM_ZEROINIT);
if(lpSort == NULL)
{
return(0);
} /* END IF */
/* Sequencing criteria - this will sort records by ABAN8 and ABALPH in ascending order */
jdeNIDcpy(lpSortlpSort[0].Item.szDict = NID_AN8);
jdeNIDcpy(lpSortlpSort[0].Item.szTable = NID_F0101);
lpSort[0].Item.idInstance = 0;
lpSort[0].nSort = JDEDB_SORT_ASC;
jdeNIDcpy(lpSortlpSort[0].Item.szDict = NID_ALPH);
jdeNIDcpy(lpSortlpSort[0].Item.szTable = NID_F0101);
lpSort[0].Item.idInstance = 0;
lpSort[0].nSort = JDEDB_SORT_ASC;
rcode = JDB_SetSequencing(hRequest, lpSort, nNumSort, JDEDB_SET_REPLACE);
if(rcode != JDEDB_PASSED)
{
printf(“JDB_SetSequencing failed\n”);
} /* END IF */