Thanks for the question, Wang.
Asked: July 12, 2019 - 6:02 am UTC
Last updated: July 25, 2019 - 5:13 am UTC
Version: 11g
Viewed 1000+ times
You Asked
//package
create or replace package P_DEFINE_TYPE3 as
type T_CODE is table of char(1) index by binary_integer;
procedure P_TEST3(P_CODE in T_CODE);
end;
//package body
create or replace package body p_define_type3 is
procedure p_test3(p_code in T_CODE) as
begin
null;
end;
end;
//use oracle.jdbc.driver.OracleDriver in Java
//cs is an Object of OracleCallableStatement
cs.setPlsqlIndexTable(1, new String[]{"1"}, 1, 1, OracleTypes.CHAR, 1);
//invoke an exception of PLS-00418: array bind type must match PL/SQL table row type
cs.execute();
// Thanks.
and Connor said...
Java isn't my strong point, but I think you need a nested table rather than associative array, ie
CREATE TYPE string_array AS TABLE OF VARCHAR2(4000);
/
CREATE OR REPLACE PROCEDURE array_proc(
p_list string_array
)
AS
BEGIN
FOR i IN 1..p_list.COUNT
LOOP
null;
END LOOP;
END;
/
Array array = ((OracleConnection) connection).createOracleArray("STRING_ARRAY", data);
CallableStatement statement = connection.prepareCall("{call array_proc(?)}");
statement.setArray(1, array);
statement.execute();
Is this answer out of date? If it is, please let us know via a Comment