Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Although the cursor is used as above, the 3. FETCH process proceeds to some extent in the CURSOR FETCH stage, and the 'ERR-410D2 (266450) Fetch out of sequence' error occurs even though there are still records to be fetched at some point.

...

Code Block
languagecpp
non-autocommit mode 

DECLARE CURSOR

OPEN CURSOR

while(1)
{
    커서(CURSOR) FETCH CURSOR;
    
    if (sqlca.sqlcode == SQL_SUCCESS) {
    
       /* Execute change DML */                     
       
       /* Perform COMMIT or ROLLBACK */ 
       
    }
    else if (sqlca.sqlcode == SQL_NO_DATA) {
       ...
    }
    else {              
      /* An error occurs at this stage when all the records in the first communication buffer are processed and then placed in the second communication buffer. */
       ...
    }   
}

...

Here are three solutions to deal with this error.

 

1. Separation of fetch session and

...

change DML session

By using multiple connections within one application, COMMIT or ROLLBACK does not affect the cursor.

  • Create a session that uses a cursor and a session that executes modified DML statements. It is described by defining it as CONN1 and CONN2, respectively.

  • Whenever cursor FETCH is executed in the session using the cursor (CONN1), change DML is executed in CONN2, and COMMIT or ROLLBACK is executed.

  • The session (CONN2) that executes the modified DML statement is set to non-autocommit mode.

...

Code Block
languagecpp
 
/* The cursor is declared using the LIMIT clause. n is the last record value to be returned in the LIMIT clause and must be defined according to the operating environment. The number of records in the communication buffer depends on the record size. */
DECLARE 커서CURSOR
         SELECT ~
           FROM ~
          WHERE ~
          LIMIT :s_start, n;
              

/* Declare the starting value used in the LIMIT clause. */
s_start = 1;
   
while(1)
{ 
    /* Cursor open is repeated until all records meeting the conditions are fetched. */                   
    OPEN CURSOR
    
		while(1)
		{
		    FETCH CURSOR ;
		    
		    if (sqlca.sqlcode == SQL_SUCCESS) {
		    
		       /* Execute change DML */   		     		       
		    }
		    else if (sqlca.sqlcode == SQL_NO_DATA) {
		       ...
		    }
		    else {              
		       ...
		    }   
		}
		
		/* Perform COMMIT or ROLLBACK */    
 
       /* Specify the starting value of the LIMIT clause. n is an example. */ 
       s_start = s_start + n ; 
        
}

CLOSE CURSOR 또는OR CLOSE RELEASE CURSOR
 

3. fetch across commit 

...

Reference

...

Differences by version

 

 

...

Depending on the Altibase version, the error messages that occur in the same situation may be different.

 

The difference in error messages that occurs when COMMIT/ROLLBACK is executed among FETCHs in a non-autocommit environment is as follows.

...