IBM / nodejs-idb-connector

A JavaScript (Node.js) library for communicating with Db2 for IBM i, with support for queries, procedures, and much more. Uses traditional callback-style syntax
MIT License
37 stars 23 forks source link

dbstmt.fetch() Ignores Orientation SQL_FETCH_RELATIVE and Offset #47

Closed abmusse closed 5 years ago

abmusse commented 5 years ago

Original report by David Russo (Bitbucket: DavidRusso, GitHub: DavidRusso).


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.

abmusse commented 5 years ago

Original comment by Xu Meng (Bitbucket: mengxumx, GitHub: dmabupt).


Refined the docs with commit 346e2cf and I will close this issue.

abmusse commented 5 years ago

Original comment by Xu Meng (Bitbucket: mengxumx, GitHub: dmabupt).


Refined corresponding debug information with commit 6cd8d8e

abmusse commented 5 years ago

Original comment by Xu Meng (Bitbucket: mengxumx, GitHub: dmabupt).


@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.

#!javascript
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));
#!shell
SetStmtAttr() attr = 10050, value = 2, sqlReturnCode = 0
GetStmtAttr() attr = 10015, value = 1, sqlReturnCode = 0
Scrollable is 1
abmusse commented 5 years ago

Original comment by Xu Meng (Bitbucket: mengxumx, GitHub: dmabupt).


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

#!javascript

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

Debug:

#!shell

SetStmtAttr() attr = 10015, value = 1, sqlReturnCode = 0
GetStmtAttr() attr = 10015, value = 0, sqlReturnCode = 0
Scrollable is 0