Page 1 of 1

use of db2a to connect to db2 database

Posted: Mon Nov 13, 2017 11:58 am
by derick_castillo
this is my code:

var db = require('/QOpenSys/QIBM/ProdData/OPS/Node6/os400/db2i/lib/db2a');
pjs.defineDisplay("display", "dericktest3.json");
function derickTest3() {
var DBname = '*LOCAL';
var userId = '********';
var passwd = '**********';
var data1 = ['test0','test1','test2'];
var sql = "SELECT NAME, DESCRIPTION FROM OBMENHDS.SFBLDGP";

var dbconn = new db.dbconn();
var connect = pjs.fiber.wrap(dbconn.conn,dbconn);
connect (DBname, userId, passwd);
var stmt = new db.dbstmt(dbconn);
var sqlexec = pjs.fiber.wrap(stmt.exec,stmt);
while (!btnexit) {
var data2 = sqlexec(sql);
name = JSON.stringify(data2);

stmt.close();
dbconn.disconn();
dbconn.close();

display.screen1.execute();

}
}
exports.run = derickTest3;


It is giving me the following error: "This fiber is already running"
does anybody know how to fix this issue?