1

我有一个正在调用程序的 SAP Cloud 应用程序。所有没有参数的过程都运行良好,但我无法让带参数的过程正常工作。我已将其范围缩小到我的 node.js 服务文件中的以下几行:

const ip = [{"PID": PID}, {"CENTERLAT": CENTERLAT}, {"CENTERLONG": CENTERLONG}, {"PTOL": PTOL}, {"ETOL": ETOL}, {"CURRLAT": CURRLAT}, {"CURRLONG": CURRLONG}, {"OPEN_CLOSE": OPEN_CLOSE}, {"LDATE": LDATE}, {"LTIME": LTIME}]
const output = await dbConn.callProcedurePromisified(sp, ip)

我得到的错误是:

{ code: -20007,
  message: 'Can not bind parameter(0).',
  sqlState: 'HY000' }
[2020-08-28T16:30:32.649Z | ERROR | 1987505]: An error occurred during serialization of the entity collection.
[2020-08-28T16:30:32.649Z | ERROR | 1987505]: Error stacktrace: SerializationError: An error occurred during serialization of the entity collection.

当我 console.log ip 时,我得到:

[ { PID: 'ab9359f1-2b72-4a4b-abf2-0295c7913b51' },
  { CENTERLAT: 32.352521 },
  { CENTERLONG: -117.632423 },
  { PTOL: 3.999999 },
  { ETOL: 5 },
  { CURRLAT: 32.321456 },
  { CURRLONG: -117.090456 },
  { OPEN_CLOSE: 'C' },
  { LDATE: '12122059' },
  { LTIME: '121259' } ]

我的程序定义是:

PROCEDURE "PointPathDistance" (IN PID NVarChar(36),
                               IN CENTERLAT Double,
                               IN CENTERLONG Double,
                               IN PTOL Double
                               IN ETOL Double,
                               IN CURRLAT Double,
                               IN CURRLONG Double,
                               IN OPEN_CLOSE NVarChar(1),
                               IN LDATE NVarChar (8),
                               IN LTIME NVarChar(8),
                               out result "USERLOCATIONS")

有任何想法吗?谢谢。

4

1 回答 1

1

我正在这样做:

const {PID, CENTERLAT, CENTERLONG, PTOL, ETOL, CURRLAT, CURRLONG, OPEN_CLOSE, LDATE, LTIME} = req.data
const ip = [{"PID": PID}, {"CENTERLAT": CENTERLAT}, {"CENTERLONG": CENTERLONG}, {"PTOL": PTOL}, {"ETOL": ETOL}, {"CURRLAT": CURRLAT}, {"CURRLONG": CURRLONG}, {"OPEN_CLOSE": OPEN_CLOSE}, {"LDATE": LDATE}, {"LTIME": LTIME}]
const output = await dbConn.callProcedurePromisified(sp, req.data)

基本上将 req.data 解构为代码数组并将其传递给 callProcedurePromisified 函数。

然后,我想为什么不直接传入 req.data 呢?如下所示:

const output = await dbConn.callProcedurePromisified(sp, req.data)

有用!!

于 2020-08-28T17:18:30.453 回答