我有 knex.js 的问题
如何在 knex.js 中使用输出调用存储过程
sp 字符串:调用 sp_start(1, @outmsg);
我需要调用那个 SP 并选择输出作为回报
我的代码:
.get('/:headerId/recount', function(req, res, next) {
knex.raw(
'Call sp_start(?,?)',[req.params.headerId, @outmsg]
)
.then(function(result) {
return;
});
})
Run Code Online (Sandbox Code Playgroud)
但它返回错误
根据nodejs代码中如何向一个mysql存储过程传入传出参数并返回存储过程结果
knex.transaction(trx => {
return knex.raw(
'Call sp_start(?,@outmsg)',
[req.params.headerId]
)
.then(res => knex.select(knex.raw('@outmsg')));
})
.then(res => console.log("Got output:", res));
Run Code Online (Sandbox Code Playgroud)
应该管用。