Pass NULL value for java.sql.Types.ARRAY of java.sql.Types.STRUCT to Oracle using Java
<p>I am trying to invoke a stored procedure from Java. The procedure accepts two parameters which are ARRAY of STRUCT. I want to pass a null value to those.</p>

<pre><code>create or replace FUNCTION inst_into_table_sp
(    
  v_array1  in cfg.t_array1_name_obj_tab,
  v_array2  in cfg.t_array2_obj_tab,
  v_var3    in varchar2,
  v_var4    in varchar2,
  v_err_msg out varchar2
)
...
</code></pre>

<p>The object and collection types are created as:   </p>

<pre><code>create or replace TYPE T_ARRAY2_OBJ AS OBJECT ( 
  code        VARCHAR2(60 CHAR),
  name        VARCHAR2(60 CHAR),
  description VARCHAR2(255 CHAR)
);
/
create or replace TYPE T_ARRAY2_OBJ_TAB IS TABLE OF CFG.T_ARRAY2_OBJ
/

create or replace TYPE T_ARRAY1_NAME_OBJ AS OBJECT ( 
  FIELD1 VARCHAR2(1 CHAR),
  FIELD2 VARCHAR2(60 CHAR),
  FIELD3 VARCHAR2(1 CHAR),
  FIELD4 VARCHAR2(60 CHAR),
  FIELD5 VARCHAR2(1 CHAR),
  FIELD6 VARCHAR2(60 CHAR)
);
/
create or replace TYPE T_ARRAY1_NAME_OBJ_TAB IS TABLE OF CFG.T_ARRAY1_NAME_OBJ
/
</code></pre>

<p>For each array I am creating a descriptor like below -</p>

<pre><code>arrayDescriptor1 = ArrayDescriptor.createDescriptor("CFG.T_ARRAY1_NAME_OBJ_TAB", oconn);
structDescriptor1 = StructDescriptor.createDescriptor("CFG.T_ARRAY1_OBJ", oconn);

Object[][] arrObj1 = new Object[3][3];
ARRAY arr1 = new ARRAY(arrayDescriptor, conn, arrObj1);

arrayDescriptor = ArrayDescriptor.createDescriptor("CFG.T_ARRAY2_OBJ_TAB", oconn);
structDescriptor = StructDescriptor.createDescriptor("CFG.T_ARRAY2_OBJ",oconn);

Object[][] arrObj = new Object[5][3];
ARRAY arr = new ARRAY(arrayDescriptor, conn, arrObj);
</code></pre>

<p>This is how I am creating Inputs </p>

<pre><code>inputs.addEntry(Types.ARRAY, input_arr_1);
inputs.addEntry(Types.ARRAY, input_arr_2);
inputs.addEntry(Types.VARCHAR, var3);
inputs.addEntry(Types.VARCHAR, var4);

PreparedStatement callableStatement = SPUtilities.prepareStoredProcedure(oracleConnection,CFG_SCHEMA,SP_TO_INSERT,inputs,outputs);
callableStatement.setNull(1,Types.ARRAY,"ARRAY");
callableStatement.setNull(2,Types.ARRAY,"ARRAY");

SPUtilities.runSP ( callableStatement );
</code></pre>

<p>But I am always getting following error - </p>

<pre><code>invalid name pattern: dbo.array
</code></pre>

<p>dbo is my username. I don't know where it is picking it up from.</p>

<p>What am I doing wrong?</p>