1 Reply Latest reply: Mar 8, 2013 10:55 AM by rp0428 RSS

    null value in PreparedStatement.setObject

    995633

      Do we have a solution for this?

      my code is something like this:

      preparedStatement.SetObject(i , MyArray);

      Here , MyArray is an array of record fetched form a table. Now , whenever the above statement finds a value null it throws an SQL exception : invalid Column type.

      Options available are to use setObject(int parameterIndex, Object x, int sqlType) or setNull , but in that case i need to provide SQL type of the target column, which doesn't seem possible.

      Thanks

        • 1. Re: null value in PreparedStatement.setObject
          rp0428
          >
          Options available are to use setObject(int parameterIndex, Object x, int sqlType) or setNull , but in that case i need to provide SQL type of the target column, which doesn't seem possible.
          >
          Why isn't it possible?

          Oracle needs to know the datatype of ANY column that it is going to put data in. Object/array columns are no different in that respect.

          See chapter 16 Working with Oracle Collections
          http://docs.oracle.com/cd/B28359_01/java.111/b31224/oraarr.htm#g1072333

          There is a section that deals with ARRAYS
          http://docs.oracle.com/cd/B28359_01/java.111/b31224/oraarr.htm#i1059642