Announcement Announcement Module
Collapse
No announcement yet.
Spring Stored Proc with Oracle Object Types Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Stored Proc with Oracle Object Types

    Is there a way to express the following code with a Spring StoredProcedure Class and defineParameter? The Problem is that I need to do a setTypeMap and a setArray with a Oracle ARRAY to pass an Oracle ObjectType before the call to execute so that the parameter is recognized as the right OracleObjectType...

    Thanks for reading,
    Stefan.


    ----

    conn = dataSource.getConnection();

    Map map = conn.getTypeMap();
    map.put(AbcVariant._SQL_NAME, AbcVariant.class);
    map.put(TExtError._SQL_NAME, OracleExtError.class);
    conn.setTypeMap(map);

    CallableStatement cs = conn.prepareCall(query);

    cs.registerOutParameter(1, Types.INTEGER);

    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor(ARRAY_TYPE_NAME, conn);
    AbcVariant[] abcVariants = new AbcVariant[1];
    abcVariants[0] = variant;
    ARRAY array = new ARRAY(descriptor, conn, abcVariants);
    cs.setArray(2, array);

    cs.registerOutParameter(3, Types.ARRAY, "IO_EXT_ERROR");

    cs.execute();

  • #2
    Use the version of the execute method which takes a ParameterMapper instead of a Map. The ParameterMapper has a createMap method which gets passed a Connection where you can create the array with the code you specified. You populate and return the map from this method.

    Comment


    • #3
      See:

      http://www.oracle.com/technology/pub...rx_spring.html

      Comment


      • #4
        Thanks

        Thanks for your help. Now it is clear and working :-)

        Comment

        Working...
        X