Skip to content

Commit 386e60a

Browse files
author
bimalkjha
committed
update test file for issue ibmdb#215
1 parent 47d54fb commit 386e60a

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Install a newer compiler or upgrade older one.
1515

1616
- You need not to install any db2 ODBC client driver for connectivity. Just install ibm_db and it is ready for use.
1717

18-
- Recommended versions of node.js is V4.x, V6.x and V7.x. Support for node.js V0.10.x is deprecated on Windows and will be discontinued soon.
18+
- Recommended versions of node.js is V4.x, V6.x and V7.x. Support for node.js V0.10.x is deprecated on Windows and will be discontinued from next release.
1919

2020
## Install
2121
------------

test/test-prepareSync-multiple-execution.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
var common = require("./common")
2-
, odbc = require("../")
3-
, db = new odbc.Database()
2+
, ibmdb = require("../")
43
, assert = require("assert")
54
;
65

76
var count = 0;
87
var iterations = 10;
98

10-
db.openSync(common.connectionString);
9+
var conn = ibmdb.openSync(common.connectionString);
1110

12-
common.dropTables(db, function () {
13-
common.createTables(db, function (err, data) {
11+
common.dropTables(conn, function () {
12+
common.createTables(conn, function (err, data) {
1413
if (err) {
1514
console.log(err);
1615

1716
return finish(2);
1817
}
1918

20-
var stmt = db.prepareSync("insert into " + common.tableName + " (colint, coltext) VALUES (?, ?)");
19+
conn.beginTransactionSync();
20+
var stmt = conn.prepareSync("insert into " + common.tableName + " (colint, coltext) VALUES (?, ?)");
2121
assert.equal(stmt.constructor.name, "ODBCStatement");
2222

2323
recursive(stmt);
@@ -27,7 +27,7 @@ common.dropTables(db, function () {
2727
function finish(retValue) {
2828
console.log("finish exit value: %s", retValue);
2929

30-
db.closeSync();
30+
conn.closeSync();
3131
process.exit(retValue || 0);
3232
}
3333

@@ -51,17 +51,22 @@ function recursive (stmt) {
5151
result.closeSync();
5252
count += 1;
5353

54-
console.log("count %s, iterations %s", count, iterations);
54+
console.log("Executing iteration %s out of %s.", count, iterations);
5555

56-
if (count <= iterations) {
56+
if (count < iterations) {
5757
setTimeout(function(){
5858
recursive(stmt);
5959
},100);
6060
}
6161
else {
62-
console.log(db.querySync("select * from " + common.tableName));
62+
console.log("Inserted Rows = ");
63+
console.log(conn.querySync("select * from " + common.tableName));
64+
conn.rollbackTransactionSync();
65+
var data = conn.querySync("select * from " + common.tableName);
66+
console.log("After roolback, selected rows = ", data);
67+
assert.deepEqual(data, []);
6368

64-
common.dropTables(db, function () {
69+
common.dropTables(conn, function () {
6570
return finish(0);
6671
});
6772
}

0 commit comments

Comments
 (0)