如何在节点js中处理oracle.sql.ARRAY?
问题描述:
我想打电话给使用节点Oracle驱动程序Oracle存储过程 - https://github.com/joeferner/node-oracle如何在节点js中处理oracle.sql.ARRAY?
我能够调用使用下面的代码的程序,但我有第二个参数(parameterArray)的问题。它需要传递一系列的项目,在java中我们使用oracle.sql.ARRAY,但是如何处理这个节点js?我当前的代码如下...
var oracle = require('oracle');
var connectData = {
hostname: "example_editted.com",
port: 1521,
database: "dev", // System ID (SID)
user: "user",
password: "password"
}
oracle.connect(connectData, function(err, connection) {
var starting_time = req.body.startDate + " 00:00:00"
var ending_time = req.body.endDate +" 00:00:00"
var parameterArray = {owner_id: req.body.accountId, time_min: null, time_max: null, duration_min: null, duration_max: null, date_format: "'MM/DD/YYYY HH24:MI:SS'", start_date: starting_time, end_date: ending_time}
connection.execute("call reporting.execute_report(:1, :2, :3)", ["ProcedureName", parameterArray,new oracle.OutParam()], function(err, results) {
的当前错误,我得到的是
Assertion failed: (handle->InternalFieldCount() > 0), function Unwrap, file /Users/johnson/.node-gyp/0.10.35/src/node_object_wrap.h, line 61.
Abort trap: 6
答
基于一个纯粹猜测,问题可能在于OCI无力结合与字符串的索引集合,您的解决方案可能是在调用存储过程并在调用存储过程之前将您的关联集合重新组合到PLSQL代码之前,将您的JS对象分解为一对常规数组,即...
.
.
.
//var parameterArray = {owner_id: req.body.accountId, time_min: null, time_max: null, duration_min: null, duration_max: null, date_format: "'MM/DD/YYYY HH24:MI:SS'", start_date: starting_time, end_date: ending_time}
var parameterArrayIndices = ["owner_id", "time_min", "time_max", "duration_min", "duration_max", "date_format", "start_date", "end_date"];
var parameterArrayValues = [req.body.accountId, null, null, null, null, "'MM/DD/YYYY HH24:MI:SS'", starting_time, ending_time];
connection.execute("
declare
i_indices dbms_sql.varchar2a;
i_values dbms_sql.varchar2a;
l_params <the_collection_type_of_the_procedure's_second_parameter>;
begin
i_indices := :1;
i_values := :2;
for i in nvl(i_indices.first,1)..nvl(i_indices.last,0) loop
l_params(i_indices(i)) := i_values(i);
end loop;
reporting.execute_report(:3, l_params, :4);
end;
", [parameterArrayIndices, parameterArrayValues, "ProcedureName", new oracle.OutParam()], function(err, results) {
通过我所看到的** ** **(没有任何node.js经验),您正试图传递字符串索引关联数组,Oracle调用接口不允许。无论你在哪里谷歌的“绑定关联数组索引varchar2”,你只会发现失败提到这样做。通过OCI传递数组/集合只允许用于整数索引的afaik。 – nop77svk 2015-01-12 07:56:27