我试图设置准备好的插入语句,但是我很难找到有关将DB2i与Node一起使用的文档。
我找到了一个网站,该网站展示了我将如何假设该功能将起作用。
var db = require('/QOpenSys/QIBM/ProdData/OPS/Node4/os400/db2i/lib/db2');
var data = {};
db.init();
db.conn(config.db_name);
db.prepare(query, function(err, stmt) {
if(err) {
console.log(err);
}
console.log(stmt);
}
问题是,stmt以未定义的形式返回,并且没有错误。我对如何设置此功能感到非常困惑,而且在任何地方都找不到文档。
我也做了一个
console.log(db.prepare.toString());
它表明一个函数存在。
答案 0 :(得分:0)
prepare
与bindParam
和execute
一起使用。 Example中的docs:
const sql = 'call QXMLSERV.iPLUG512K(?,?,?,?)';
// note 4 params
const params = [[ipc, IN, CHAR],
[ctl, IN, CHAR],
[xmlIn, IN, CLOB],
[xmlOut, OUT, CLOB],
];
const statement = new dbstmt(connection);
statement.prepare(sql, (error) => {
if (error) {
throw error;
}
statement.bindParam(params, (error) => {
if (error) {
throw error;
}
statement.execute((out, error) => {
if (error) {
throw error;
}
statement.close();
});
});
});