dbstmt.fetch() Ignores Orientation SQL_FETCH_RELATIVE and Offset

Issue #46 resolved
David Russo created an issue

The fetch() call seems to ignore orientation == SQL_FETCH_RELATIVE and offset. See attached example script. The first fetch() call should move the cursor 10 rows from the start of the result set.

Run the script and compare the results vs. running the same query interactively. The results are identical, meaning the fetch() call with SQL_FETCH_RELATIVE did not move the cursor 10 rows.

Comments (6)

  1. mengxumx Account Deactivated

    Hello @DavidRusso , Seems the scrollable attribute is not set succesfully -->

    dbstmt.setStmtAttr(db2i.SQL_ATTR_CURSOR_SCROLLABLE, db2i.SQL_TRUE);
    console.log("Scrollable is " + dbstmt.getStmtAttr(db2i.SQL_ATTR_CURSOR_SCROLLABLE));
    

    Debug:

    SetStmtAttr() attr = 10015, value = 1, sqlReturnCode = 0
    GetStmtAttr() attr = 10015, value = 0, sqlReturnCode = 0
    Scrollable is 0
    
  2. mengxumx Account Deactivated

    @DavidRosson Seems we can not set the scrollable attribute directly. We have to set the cursor type to SQL_CURSOR_DYNAMIC then the cursor become scrollable automatically.

    dbstmt.setStmtAttr(db2i.SQL_ATTR_CURSOR_TYPE, db2i.SQL_CURSOR_DYNAMIC);
    // dbstmt.setStmtAttr(db2i.SQL_ATTR_CURSOR_SCROLLABLE, db2i.SQL_TRUE);
    console.log("Scrollable is " + dbstmt.getStmtAttr(db2i.SQL_ATTR_CURSOR_SCROLLABLE));
    
    SetStmtAttr() attr = 10050, value = 2, sqlReturnCode = 0
    GetStmtAttr() attr = 10015, value = 1, sqlReturnCode = 0
    Scrollable is 1
    
  3. Log in to comment