Access to NumRows() -> SQLCODE=8014 There is no result set to be queried.

Issue #6 resolved
Former user created an issue

I cannot call NumRows() function with UPDATE or INSERT SQL statement..

My code:

var sql = "UPDATE TABLE  SET...  WHERE ";

const db2a = require('/QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/lib/db2a')
const dbconn = new db2a.dbconn() ;
dbconn.conn("*LOCAL");
const stmt = new db2a.dbstmt(dbconn);

stmt.exec(sql, function (result, err) {
  if (err) console.log(err);
  else {
          console.log(result);
          stmt.stmtError(db2a.SQL_HANDLE_STMT, 1, function (ErrMsg) {
               console.log("Error retrieved");
               console.log(ErrMsg);
           });
           console.log("numrow updated " + stmt.numRows());
        }
}

Result :

console.log("numrow updated " + stmt.numRows());
                                     ^
Error: SQLSTATE=PAERR SQLCODE=8014 There is no result set to be queried. Please execute a SQL command first.
    at Error (native)
    at Object.db.query (/home/storebot2/TestNewDriverUpdate.js:51:44)
    at Object.<anonymous> (/home/storebot2/TestNewDriverUpdate.js:90:4)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)

I tried with exec and execSync.. same... I kept "auto commit =true", table is journalised .... With a SELECT statement, it works and return -1, that is good. An idea ? System: v7r3, PTF Group SF99225 is Level 3, SF99703 Level 4, SF99722 Level 7)

Thx

Comments (6)

  1. mengxumx Account Deactivated

    The code

    CHECK(obj->resultSetAvailable == false, RSSET_NOT_READY, "There is no result set to be queried. Please execute a SQL command first.", isolate);
    

    from dbstmt.cc has problems. For the UPDATE action, there is no availble result set but we should able to call this fucntion as well. I will remove this line later.

  2. Log in to comment