I'm attempting to pass an array of numbers to an oracle stored procedure so I can process in bulk. I have to pass the associative array in and then populate a nested table with the contents. Is there a better way to pass an array of numbers or varchar2 to a stored procedure in oracle? Am I doing this right? :)
I've looked at temp tables and pipeline functions too as alternatives to this working method below.
create or replace type t_number_table as table of number;
create or replace package numberarray_pkg
as
type t_numbers is table of number index by pls_integer;
type t_cursor is ref cursor;
procedure passarray(
paymentids in t_numbers,
io_cursor in out t_cursor);
end numberarray_pkg;
/
create or replace package body numberarray_pkg
as
procedure passarray(paymentids in t_numbers, io_cursor in out t_cursor) as
v_number_table t_number_table;
v_cursor t_cursor;
begin
v_number_table := t_number_table();
v_number_table.extend(paymentids.count);
for i in 1 .. paymentids.count loop
v_number_table(i) := paymentids(i);
end loop;
open v_cursor for
select column_value from table(v_number_table);
io_cursor := v_cursor;
end passarray;
end numberarray_pkg;
/
new OracleParameter { ParameterName = "payment_ids", OracleDbType = OracleDbType.Int32, CollectionType = OracleCollectionType.PLSQLAssociativeArray, Value = array, Size = array.Length }Thanks for looking at my question, Alex. - Jonathan F