如何在节点 js 中处理 oracle.sql.ARRAY?
How to handle a oracle.sql.ARRAY in node js?
我正在尝试使用节点 oracle 驱动程序调用 Oracle 存储过程 - https://github.com/joeferner/node-oracle
我可以使用以下代码调用过程,但第二个参数 (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 无法绑定字符串索引集合,您的解决方案可能是将您的 JS 对象分解为一对常规在调用存储过程之前创建数组并在调用存储过程之前在 PLSQL 代码中重组关联集合,即 ...
.
.
.
//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) {
我正在尝试使用节点 oracle 驱动程序调用 Oracle 存储过程 - https://github.com/joeferner/node-oracle
我可以使用以下代码调用过程,但第二个参数 (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 无法绑定字符串索引集合,您的解决方案可能是将您的 JS 对象分解为一对常规在调用存储过程之前创建数组并在调用存储过程之前在 PLSQL 代码中重组关联集合,即 ...
.
.
.
//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) {