0

我正在尝试在以下链接中提到的过程中传递数组,但该数组应该是可选的。我在过程中使用 forall 进行批量插入。但是某些时间列表也可能为空,并且程序中的其他内容也应该成功执行。

https://github.com/oracle/node-oracledb/blob/master/doc/api.md#plsqlindexbybinds

connection.execute(
  "BEGIN mypkg.myinproc(:id, :vals); END;",
  [
    1234,
    { type: oracledb.NUMBER,
       dir: oracledb.BIND_IN,
       val: [1, 2, 23, 4, 10]
    }
  ],

  function (err) { . . . });

可以找到但如果我不想通过 vals 我会收到错误

我试过了

val:[]
val: null
val: undefined

and not having val at all

我收到以下错误消息

尝试传递 null 或 undefined 或不传递时:

PLS-00306: wrong number or types of arguments in call to 'INSERT_PROCEDURE'

尝试传递空数组时

NJS-039: empty array is not allowed for IN bind

我通过使用 null 传递数组来解决问题

 val:[null]

并在执行 FORALL 之前从列表中删除空值的过程中。

这适用于临时,但我真的很想以适当的方式解决这个问题。

4

1 回答 1

1

我将把它视为一个错误(或设计缺陷)并让某人查看它。PHP OCI8 2.0 和 Node node-oracledb 1.11 都不允许绑定空数组,但 Python cx_Oracle 不允许。

于 2016-11-19T01:07:28.050 回答