Forum Stats

  • 3,781,146 Users
  • 2,254,484 Discussions
  • 7,879,595 Comments

Discussions

Java jdbc oracle bug

2687365
2687365 Member Posts: 7

I just simplified my code so anyone can reproduce the problem. Database data is:

    CREATE OR REPLACE TYPE HBD."MY_OBJECT" AS OBJECT

    (

    VALUE VARCHAR2(1)

    )

    /

   

    CREATE OR REPLACE TYPE HBD."MY_COLLECTION" AS TABLE OF MY_OBJECT

    /

   

    CREATE OR REPLACE PACKAGE HBD.MY_PACKAGE

    IS

       --Obtener detalle de un contrato

       PROCEDURE MY_STORED_PROCEDURE (

          out_value OUT NOCOPY HBD.MY_COLLECTION

       );

    END MY_PACKAGE;

    /

   

    CREATE OR REPLACE PACKAGE BODY HBD.MY_PACKAGE

    IS

       --Obtener detalle de un contrato

       PROCEDURE MY_STORED_PROCEDURE (

          out_value OUT NOCOPY HBD.MY_COLLECTION

       )

       IS

       BEGIN

          out_value := MY_COLLECTION();

          FOR i IN 1..10920 LOOP

            out_value.EXTEND;

            out_value := NEW MY_OBJECT ('A');

          END LOOP;

       END;

    END MY_PACKAGE;

    /

My java code is:

    public static void main(String[] args) throws SQLException,

  MalformedObjectNameException, NullPointerException,

  AttributeNotFoundException, InstanceNotFoundException,

  MBeanException, ReflectionException {

  System.out.println("Start");

  Connection connection = DriverManager.getConnection(

  "XXX", "YYY", "ZZZ");

  String PROCEDURE = "{call MY_PACKAGE.MY_STORED_PROCEDURE(?)}";

  CallableStatement cs = connection.prepareCall(PROCEDURE);

  cs.registerOutParameter(1, Types.ARRAY, "MY_COLLECTION");

  cs.execute();

  Array array = cs.getArray(1);

  if (array == null) {

  System.out.println("array == null");

  } else {

  System.out.println("array != null");

  }

  cs.close();

  connection.close();

  System.out.println("End");

  }

As you can see in the stored procedure there's a 10920. If I change this value to any other value. The output of the code will result in: array!=null. With the 10920 the output is: array==null.


I tried values between 1 and 20000.

Thanks in advance.

Joan

Tagged:

Answers

This discussion has been closed.