我在输入数据时未定义如何修复它?
这是我的代码:
const {sql,poolPromise} = require('../config/winauth paperless')
exports.Checkskip = async function(req, res) {
try {
const pool = await poolPromise;
const result = await pool.request()
.input('a', sql.VarChar, req.body.TagAlternateKey)
.input('b', sql.Int, req.body.ProcessOfProductionKey)
.query("execute [wos].[StoredInternalProcessTransactionCheckProcessBeforeReceiving ]@a , @b " ,function(err, result)
{
if (err) {
console.log(err)
}
else {
res.json(result.recordset);
console.log(result.recordset)
}
})
}catch (err){
res.status(500)
res.send(err.message)
}
}
在req.body
输入数据
定义
我得到了它,我在。input下添加OUTPUT,在sql中添加return_value,像这样
exports.Checkskip = async function(req, res) {
try {
const pool = await poolPromise;
const result = await pool.request()
.input('a', req.body.TagAlternateKey)
.input('b', req.body.ProcessOfProductionKey)
.output('return_value', sql.Int)
.query("execute @return_value = [wos].[StoredInternalProcessTransactionCheckProcessBeforeReceiving] @a , @b ; SELECT 'Return Value' = @return_value" ,function(err, result)
{
if (err) {
console.log(err)
}
else {
res.json(result.recordset);
console.log(result.recordset)
}
})
}catch (err){
res.status(500)
res.send(err.message)
}
}`
感谢大家对我的帮助