实际上,上述方法对我使用"mssql": "^4.3.0"
.
我不得不使用 promise 返回的结果对象并从output
对象中提取参数。就像是:
资源输出。
这是对我有用的示例代码:
poolPromise
.then(conn => conn.request())
.then(request => {
const forecastName = forecastDefinition.name;
// Input parameters
request.input('forecastName', sql.VarChar(50), forecastName);
...
// Output parameters
request.output('actualYear', sql.Int);
request.output('actualMonth', sql.Int);
...
return request.execute('[dbo].[' + generateForecastProcedure + ']')
})
.then((res, err) => {
if (err) {
console.log(`${generateForecastProcedure} error: `, err);
} else {
console.log(`${generateForecastProcedure} success: `, res);
// Callback to deal with further processing.
const output = (res.output || {});
const actualYear = output.actualYear;
const actualMonth = output.actualMonth;
callback(forecastDefinition, actualYear, actualMonth);
}
})
.catch(err => {
console.log(`${generateForecastProcedure} exception: `, err);
})