Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executeNonQuerySync Wrong number of parameters. SQLSTATE=07001 #595

Closed
debrajo opened this issue Nov 25, 2019 · 1 comment
Closed

executeNonQuerySync Wrong number of parameters. SQLSTATE=07001 #595

debrajo opened this issue Nov 25, 2019 · 1 comment

Comments

@debrajo
Copy link

debrajo commented Nov 25, 2019

I've been trying to find correct coding syntax to perform a beginTransaction, prepareSync insert SQL with 2 executeNonQuerySync with a error / row checking for a commit/rollback. I've tried both beginTransaction and beginTransactionSync and I continued to receive the error from title.

I've reproduced the error to this small code. Any help/direction would be appreciated.
node.js : v10.16.0
npm : 6.9.0
ibm_db : [email protected]
copy db2consv_zs.lic node_modules\ibm_db\installer\clidriver\license

executeNonQuery.js

/**
 * Db2 for z/OS,  
 * DSN11015 : Db2 11 in new-function mode   
CREATE TABLE U246149.TESTS01 (                                    
  RPT_YEAR CHAR(4) NOT NULL,                                       
  RPT_MONTH CHAR(2) NOT NULL                                      
) IN U246149.QMFSAVEU                                             
 AUDIT NONE DATA CAPTURE NONE CCSID UNICODE NOT VOLATILE APPEND NO ;
 * 
 */

var ibmdb = require('ibm_db');
var connString = "DRIVER={DB2};DATABASE=DSND;UID=xxxxx;PWD=V3stGood;HOSTNAME=iccmvs1.pok.ibm.com;port=6000"
try {
    ibmdb.debug(true);  // **==> ENABLE CONSOLE LOGS. <==**
    ibmdb.open(connString, function (err, conn) {
        if (err) return console.log(err);
        console.log("prepareSync starting")
        var stmt = conn.prepareSync("INSERT INTO U246149.TESTS01 (RPT_YEAR , RPT_MONTH)  VALUES (?, ?)") //testTable
        var affectedRowCount = stmt.executeNonQuerySync(['2019', '10'])
        console.log("insertStaging insert newRow success: Affected rows = " + affectedRowCount);
        conn.closeSync(function (err) { console.log("commitTransactionSync Connection Closed after success."); });
    });
} catch (error) {
    console.log(' Fatal error')
    console.log(error.message);
}

Console Log:
node executeNonQuery

`node-ibm_db logs enabled.
prepareSync starting
C:\Users\DebraJohnson\projects\git\src\github.ibm.com\debrajo\db2_client\executeNonQuery.js:21
        var affectedRowCount = stmt.executeNonQuerySync(['2019', '10'])
                                    ^
Error: [IBM][CLI Driver] CLI0100E  Wrong number of parameters. SQLSTATE=07001
    at C:\Users\DebraJohnson\projects\git\src\github.ibm.com\debrajo\db2_client\executeNonQuery.js:21:37
    at C:\Users\DebraJohnson\projects\git\src\github.ibm.com\debrajo\db2_client\node_modules\ibm_db\lib\odbc.js:111:11
    at C:\Users\DebraJohnson\projects\git\src\github.ibm.com\debrajo\db2_client\node_modules\ibm_db\lib\odbc.js:335:11

`

@bimalkjha
Copy link
Member

@debrajo Currently executeNonQuerySync() ignores any parameters passed to it. So, no parameter is binded and hence error by executeNonQuerySync().
To avoid it, you can call stmt.bindSync([params]) first and then call stmt.executeNonQuerySync(). That should work. So, below code from your test program should work.

          var stmt = conn.prepareSync("INSERT INTO U246149.TESTS01 (RPT_YEAR , RPT_MONTH)  VALUES (?, ?)") //testTable
         stmt.bindSync(['2019', '10']);
        var affectedRowCount = stmt.executeNonQuerySync();

Above is a work around. You can hitting this issue due to some missing code. Code for executeNonQuerySync() is missing in ibm_db/lib/odbc.js file. I'll deliver the fix soon. Thanks.

bimalkjha added a commit that referenced this issue Dec 3, 2019
* doc: Docker Linux Container instructions

* support for install --debug option on windows

* fix: blob data corruption issue #582

* doc: update doc for executeNonQuerySync API, issue #583

* force push connection to the queue when poolSize breaches maxPool boundry (#581)

* Support for node v12 on z/OS, and fix some test cases for z/OS (#586)

* fix: update unzipper version, issue #588

* fix: use v8::Isolate for nodev >= 11

* fix: ignore sqlcode 100 by executeNonQuery, issue #591

* fix: add executeNonQuerySync in odbc.js issue #595
bimalkjha added a commit that referenced this issue Dec 9, 2019
 * doc: update for issue #593 (Bimal Jha)
 * fix: update windows binary using latest code (Bimal Jha)
 * fix: for memory leak issue #576 (Bimal Jha)
 * fix: update windows binary for vscode 1.40.x (Bimal Jha)
 * update windows binaries (Bimal Jha)
 * fix: add executeNonQuerySync in odbc.js issue #595 (Bimal Jha)
 * fix: ignore sqlcode 100 by executeNonQuery, issue #591 (Bimal Jha)
 * fix: use v8::Isolate for nodev >= 11 (Bimal Jha)
 * fix: update unzipper version, issue #588 (Bimal Jha)
 * Support for node v12 on z/OS, and fix some test cases for z/OS (#586) (alexcfyung)
 * force push connection to the queue when poolSize breaches maxPool boundry (#581) (ashutoshrnjn)
 * doc: update doc for executeNonQuerySync API, issue #583 (Bimal Jha)
 * fix: blob data corruption issue #582 (Bimal Jha)
 * support for install --debug option on windows (Priyanka Manoharan)
 * doc: Docker Linux Container instructions (Bimal Jha)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants