This document describes an error that occurs during the record fetch process by using a cursor to process a select statement that returns multiple records.
Altibase 4.3.9
To process a query statement that returns multiple records, a CURSOR must be used in the following process.
Although the cursor is used as above, the 3. FETCH process proceeds to some extent in the CURSOR FETCH stage, and the 'ERR-4103C (266300)' error Request of fetching data to an unprepared SQL statement.' occurs even though there are still records to be fetched at some point.
Below is an example where an error occurs when using the cursor and the result of the error.
DECLARE CURSOR OPEN CURSOR /* fetch cursor in loop */ /* To retrieve all records that meet the conditions, the FETCH CURSOR statement is repeatedly executed until the execution result is SQL_NO_DATA. */ while(1) { 커서(CURSOR) FETCH ; if (sqlca.sqlcode == SQL_SUCCESS) { ... } else if (sqlca.sqlcode == SQL_NO_DATA) { ... } else { /* Even though there are records to be fetched at some point after fetching to some extent, the error 'ERR-4103C (266300) Request of fetching data to an unprepared SQL statement.' occurs.*/ printf("Error : [%d] %s\n", SQLCODE, sqlca.sqlerrm.sqlerrmc); break; } } |
$ ./cursor1 <CURSOR 1> [Success declare cursor] [Success open cursor] [Fetch Cursor] ------------------------------------------------------------------ DNO DNAME DEP_LOCATION MGR_NO ------------------------------------------------------------------ 1 BUSINESS DEPT Seoul 100 2 BUSINESS DEPT Seoul 100 ...Omitted... 908 BUSINESS DEPT Seoul 100 909 BUSINESS DEPT Seoul 100 Error : [-266300] Request of fetching data to an unprepared SQL statement. /* Error occurred while performing fetch */ ------------------------------------------------------------------ [Close Cursor] ------------------------------------------------------------------ Success close cursor |
Altibase complies with the ANSI standard and is configured not to support the fetch across commit method by default. Therefore, if COMMIT or ROLLBACK is performed after opening the cursor, the cursor is forcibly closed according to the ANSI standard.