0

I want invoke a oracle function which is take one in parameter type of oracle types and one out parameter type of oralce types.

code :

Connection connection = (Connection) parameters.get(SwingBenchTask.JDBC_CONNECTION);
boolean success = true;
// getObjArray returns one object array with values
Object[] object2Values = getObjArray("input.txt");
oracle.sql.StructDescriptor structDesc = oracle.sql.StructDescriptor.createDescriptor(typeName, connection);
oracle.sql.STRUCT object1 = new oracle.sql.STRUCT(structDesc, connection, object2Values);
String query = "{call ? :=change_offer(?,?)}";
CallableStatement stmt = connection.prepareCall(query);
long executeStart = System.nanoTime();
try
{
    stmt.registerOutParameter(1, OracleTypes.NUMBER);
    stmt.setObject(2, object1, OracleTypes.STRUCT);
    stmt.registerOutParameter(3, OracleTypes.STRUCT, OutTypeName);
    stmt.execute();
    stmt.close();
} catch (Exception ex)
{
    success = false;
    System.err.println("Error :" + ex);
}

the constructor of class oralce.sql.STRUCT throws following exception

java.sql.SQLException: ORA-01427: single-row subquery returns more than one row

5
  • 1
    if you provide some code it would be easier to help you. My guess is that your sql returns multiple row but you only use one struct. Commented Oct 20, 2011 at 6:56
  • thanks @Marthin. its throws exception while create the object1. at that time no queries executed. Commented Oct 20, 2011 at 9:59
  • Please, post the code of change_offer(?,?). I suspect the error resides in that stored function, not in your JDBC logic Commented Oct 20, 2011 at 10:20
  • @LukasEder : exception occurred in following line oracle.sql.STRUCT object1 = new oracle.sql.STRUCT(structDesc, connection, object2Values); . After that only am invoking change_offer(?,?) function. Commented Oct 20, 2011 at 10:33
  • @Srini2k6: I'm sorry, I missed that fact Commented Oct 20, 2011 at 13:04

1 Answer 1

1

I fix the error. I give the type name with schema name.

oracle.sql.StructDescriptor structDesc = oracle.sql.StructDescriptor.createDescriptor(schema.typeName, connection);
oracle.sql.STRUCT object1 = new oracle.sql.STRUCT(structDesc, connection, object2Values);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.