Results 1 to 4 of 4

Thread: Spring Stored Proc with Oracle Object Types

  1. #1
    Join Date
    Nov 2005
    Posts
    2

    Default 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. #2
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    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.
    Bill

  3. #3
    Join Date
    Sep 2004
    Location
    Christchurch, New Zealand
    Posts
    73

  4. #4
    Join Date
    Nov 2005
    Posts
    2

    Default Thanks

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •