Am porting a Postgres PLPGSQL function to an Oracle stored procedure, but it has a TEXT[] array as a parameter, then uses this parameter in an ANY operation - specifically:
create or replace function func_name
(
...
in_array_param text[],
...
)
as $$
declare
begin
...
select column_1,
column_2
from table_x
where (column_a = value)
and (column_b = any(in_array_param));
...
end;
I don't recall Oracle historically having an equivalent to this (using a PL/SQL array in SQL), but with the evolution of PL/SQL, am wondering if there are now options to do this? Am using Oracle 19c, but can move to 21c if there is a newer construct that would help.
I have tried using a VARRAY, and using the IN operator:
type my_array_type is varray(10) of varchar2(255);
var_array my_array_type := my_array_type('1', '2', '3');
procedure my_test(param_a varchar2, param_b my_array_type) is
var_col test_tab.col2%type;
begin
select col2 into var_col
from test_tab
where col1 in param_b;
end my_test;
my_test('2', var_array);
This results in a PLS-00642 error:
ORA-06550: line 11, column 21:
PLS-00642: local collection types not allowed in SQL statements