更新查询在node-oracledb模块中挂起
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了更新查询在node-oracledb模块中挂起相关的知识,希望对你有一定的参考价值。
我正在使用node-oracledb(3.1.2)模块。一切正常,除了更新查询。我能够激活select,插入查询,但是当我尝试触发查询时,似乎查询被挂起(没有错误,没有结果)。我正在编写以下代码:
用于创建连接:
module.exports.createErpConnection = async () => {
try {
connection = await oracleDB.getConnection({
user: constants.databaseCredentials.user,
password: constants.databaseCredentials.password,
connectString: `${constants.databaseCredentials.connectString}/${constants.databaseCredentials.databaseName}`
});
if (connection) {
response.status = 1;
response.connection = connection
} else {
response.status = 0;
response.message = constants.databaseStatus.ERP_DATABASE_CONNECTION_NOT_ESTABLISHED
}
} catch (exception) {
response.status = 0;
response.message = exception;
} finally {
return response;
}
};
点火更新查询:
async function updateProductStatInErp(connection) {
let sql = `UPDATE product_master SET UPDATED_STAT='N'`;
let options = {outFormat: oracledb.OBJECT, autoCommit: true};
const res = await connection.connection.execute(sql, {}, options)
// I am not getting either response nor error
}
我是否需要为更新查询执行任何操作?
答案
我只是通过在try和catch块中编写execute语句来解决这个问题。这是代码:
try {
const res = await connection.connection.execute(sql, {}, options)
console.log('======= 185 =======', res)
} catch (exception) {
console.log('====== 186 =====', exception)
}
Result =>> ====== 185 ======= { rowsAffected: 490 }
以上是关于更新查询在node-oracledb模块中挂起的主要内容,如果未能解决你的问题,请参考以下文章
Ktor HttpClient 在 runBlocking 中挂起