Adam “Adamlivinlife” Kamal
2023-08-11 19:15:28 UTC
I have a SQL cursor that is used to retrieve records from parts table. The program is designed to return no more than 5000 records per read, then it closed the cursor.
In case if there are more records than 5000, it saves off record number 5001 and use it to reopen the cursor and get the rest of the records.
The issue appears to be not all records is returned on the second read.
The cursor look like this
EXEC SQL DECLARE QUERY_PARTS_COUNT CURSOR FOR
SELECT COMPANY
, WAREHOUSE
, REPORT_NUMBER
, SOURCE_OF_SUPPLY
, PART_NUM
, BIN_LOC
FROM =PARTS FOR BROWSE ACCESS
WHERE COMPANY = :SEARCH-COMPANY AND
WAREHOUSE = :SEARCH-WAREHOUSE AND
REPORT_NUMBER = :SEARCH-REPORT-NUMBER AND
SOURCE_OF_SUPPLY >= :SEARCH-SOS AND
PART_NUM >= :SEARCH-PART-NUM AND
BIN_LOC >= :SEARCH-BIN-LOC AND
ORDER BY COMPANY_GROUP, WARE ,REPORT_NUMBER, SOURCE_OF_SUPPLY, PART_NUM, BIN_LOC, ALT_BIN ASC
END-EXEC.
On the second read/Open cursor, it returns the record which was saved off to use it to reopen the cursor. but then it skips a bunch of records. I was hoping someone would be able to tell me what am i doing wrong in the cursor. Thanks in advance and have a wonderful weekend !
In case if there are more records than 5000, it saves off record number 5001 and use it to reopen the cursor and get the rest of the records.
The issue appears to be not all records is returned on the second read.
The cursor look like this
EXEC SQL DECLARE QUERY_PARTS_COUNT CURSOR FOR
SELECT COMPANY
, WAREHOUSE
, REPORT_NUMBER
, SOURCE_OF_SUPPLY
, PART_NUM
, BIN_LOC
FROM =PARTS FOR BROWSE ACCESS
WHERE COMPANY = :SEARCH-COMPANY AND
WAREHOUSE = :SEARCH-WAREHOUSE AND
REPORT_NUMBER = :SEARCH-REPORT-NUMBER AND
SOURCE_OF_SUPPLY >= :SEARCH-SOS AND
PART_NUM >= :SEARCH-PART-NUM AND
BIN_LOC >= :SEARCH-BIN-LOC AND
ORDER BY COMPANY_GROUP, WARE ,REPORT_NUMBER, SOURCE_OF_SUPPLY, PART_NUM, BIN_LOC, ALT_BIN ASC
END-EXEC.
On the second read/Open cursor, it returns the record which was saved off to use it to reopen the cursor. but then it skips a bunch of records. I was hoping someone would be able to tell me what am i doing wrong in the cursor. Thanks in advance and have a wonderful weekend !