注册

nodejs调用DM存储过程,提示无效的参数

海王星 2025/01/18 342 1

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:DM8
【操作系统】:WIN10
【CPU】:
【问题描述】
一:存储过程
CREATE OR REPLACE PROCEDURE getEmployeeCount(
v_cityname IN VARCHAR2,
employeeCount OUT NUMBER
) AS
BEGIN
SELECT COUNT(
) INTO employeeCount
FROM employee
WHERE city = v_cityname;
EXCEPTION
WHEN NO_DATA_FOUND THEN
employeeCount := 0;
END;

二:调用存储过程
async function callStoredProcedure() {
const dbUtils = new DatabaseUtils();
let conn = null;
try {
conn = await dbUtils.getConnection();
// 准备调用存储过程的参数
const inParams = {
v_cityname: 'Beijing'
};
const outParams = {
employeeCount: { dir: dmdb.BIND_OUT, type: dmdb.NUMBER }
};

// 调用存储过程
const result = await conn.execute({
procedure: 'getEmployeeCount',
inParams: inParams,
outParams: outParams
});

// 输出存储过程的返回结果
console.log('Employee count in Beijing:', outParams.employeeCount.value);
} catch (err) {
console.error('Error calling stored procedure:', err.message);
} finally {
if (conn) {
conn.close();
}
}
}

callStoredProcedure();

/Error calling stored procedure: [20001] 无效的参数/

回答 0
暂无回答
扫一扫
联系客服