Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[BUG] callProcedure returns parameter values of incorrect datatype

未关闭
#378 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
领域
database

调研方向

从 callProcedure 入口点开始,使用 issue 中所示的 INOUT 和 OUT 定义重现报告的 DB2 for i 案例。跟踪参数值和 ODBC 过程数据的转换方式;当两种情况下的 DECIMAL(11,2) 结果都具有一致的数值和类型,并且在 repository 提供合适的测试位置时包含回归测试覆盖,即视为完成。

由索引模型根据 Issue 内容生成。

描述

confirmed
  • odbc Package Version: 2.4.8
  • ODBC Driver: unixODBC 2.3.9
  • Database Name: DB2 for i
  • Database Version: V7R5
  • Database OS: IBM i
  • Node.js Version: v18.20.2
  • Node.js OS: IBM i

When using callProcedure I'm finding the returned results don't respect the datatype of the procedure parameters but instead appear to respect the datatype of the Node.js fields.

For example, if I create the following procedure.

DROP PROCEDURE RMTEMP.MY_PROC ;

CREATE PROCEDURE RMTEMP.MY_PROC (
  INOUT PARAM1 DECIMAL(11,2) ,
  INOUT PARAM2 DECIMAL(11,2) ,
  INOUT PARAM3 DECIMAL(11,2) ,
  INOUT PARAM4 DECIMAL(11,2)
)
BEGIN
  SET PARAM1 = 123.45;
  SET PARAM2 = 123.45;
  SET PARAM3 = 123.45;
  SET PARAM4 = 123.45;
END;

-- CALL RMTEMP.MY_PROC(99.99, 0, '99.99', null);

With the following Node.js code.

const odbc = require('odbc');

odbc.connect('DSN=MYIBMI', (error, connection) => {
  if (error) { throw error; }

  let param1=99.99;
  let param2=0;
  let param3='99.99';
  let param4=null;

  connection.callProcedure(null, 'RMTEMP', 'MY_PROC', [param1, param2, param3, param4], (error, result) => {
    if (error) { throw error; }

    connection.close();
    console.log(result);
  });
});

When I call this from Node I'm expecting all four parameters to have a return value of 123.45 (as numbers) but instead I get this. Of particular concern is the second parameter, which is returned as an integer, though I would expect all values to be returned as numbers rather than strings.

[
  statement: '{ CALL RMTEMP.MY_PROC (?,?,?,?) }',
  parameters: [ 123.45, 123, '123.45', '123.45' ],
  return: undefined,
  count: 0,
  columns: []
]

If I change the procedure to all OUT parameters I get a different result.

DROP PROCEDURE RMTEMP.MY_PROC ;

CREATE PROCEDURE RMTEMP.MY_PROC (
  OUT PARAM1 DECIMAL(11,2) ,
  OUT PARAM2 DECIMAL(11,2) ,
  OUT PARAM3 DECIMAL(11,2) ,
  OUT PARAM4 DECIMAL(11,2)
)
BEGIN
  SET PARAM1 = 123.45;
  SET PARAM2 = 123.45;
  SET PARAM3 = 123.45;
  SET PARAM4 = 123.45;
END;

Running the same Node.js code I get the following. At least I'm getting the correct values but all of the parameters are returned as strings rather than numbers.

[
  statement: '{ CALL RMTEMP.MY_PROC (?,?,?,?) }',
  parameters: [ '123.45', '123.45', '123.45', '123.45' ],
  return: undefined,
  count: 0,
  columns: []
]
主要语言
JavaScript
星标
159
派生
92
平均合并
3 分钟
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

IBM/node-odbc 的其他 Issue

查看 IBM/node-odbc 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。