Hello,
I have below code in my program:
EXEC SQL
PREPARE MyStatement FROM :SearchString;
EXEC SQL
DECLARE MyCursor SCROLL CURSOR FOR MyStatement;
EXEC SQL
OPEN MyCursor;
EXEC SQL
GET DIAGNOSTICS : DetailsPage.AllRecords = DB2_NUMBER_ROWS;
Offset = ((PageNumber - 1) * PAGE_SIZE) + 1;
EXEC SQL
FETCH RELATIVE :Offset
FROM MyCursor
FOR :PageSize ROWS
INTO : DetailsData;
DetailsPage.Count = SQLERRD(3);
DetailsPage.DetailsData = DetailsData;
EXEC SQL
CLOSE MyCursor;
AllRecords is integer(5)
SearchString holds sql (1200 characters) statement which returns 245 records but DB2_NUMBER_ROWS return 11192. When I run this sql from strsql number of records is correct. SQLERRD(3) also return correct numbers of rows (9 per page which is subfile page)
I thought this bug was fixed in 2016. Any idea why this does not work? My friend has the same code but of course different sql statement and table and it returns correct numbers of rows.
I have below code in my program:
EXEC SQL
PREPARE MyStatement FROM :SearchString;
EXEC SQL
DECLARE MyCursor SCROLL CURSOR FOR MyStatement;
EXEC SQL
OPEN MyCursor;
EXEC SQL
GET DIAGNOSTICS : DetailsPage.AllRecords = DB2_NUMBER_ROWS;
Offset = ((PageNumber - 1) * PAGE_SIZE) + 1;
EXEC SQL
FETCH RELATIVE :Offset
FROM MyCursor
FOR :PageSize ROWS
INTO : DetailsData;
DetailsPage.Count = SQLERRD(3);
DetailsPage.DetailsData = DetailsData;
EXEC SQL
CLOSE MyCursor;
AllRecords is integer(5)
SearchString holds sql (1200 characters) statement which returns 245 records but DB2_NUMBER_ROWS return 11192. When I run this sql from strsql number of records is correct. SQLERRD(3) also return correct numbers of rows (9 per page which is subfile page)
I thought this bug was fixed in 2016. Any idea why this does not work? My friend has the same code but of course different sql statement and table and it returns correct numbers of rows.