Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> varray descriptor in java - invalid name pattern - arg!!!
I am desperately trying to use a VARRAY to insert multiple records to
two tables within the same stored procedure call.
oracle 8.1.7 + java 3.0.2
I am trying the code below (found online)
The stored procedure exists and is valid, the db connection is fine
too.
I get a runtime error --> "invalid name pattern:
<schema>.number_varray"
Does anyone know why??????? ARG!!
public void testVARRAY() throws SQLException{
// Get a connection from the connection pool
DatabaseManager dbmanager = DatabaseManager.getInstance();
Connection con = null;
CallableStatement cstmt = null;
try {
con = (dbmanager.getConnectionPool()).getConnection();
Statement s = con.createStatement();
s.execute("CREATE TYPE number_varray AS VARRAY(10) OF NUMBER(12,2)");
// Create an oracle.sql.ARRAY object to hold the values
oracle.sql.ArrayDescriptor arrayDesc =
oracle.sql.ArrayDescriptor.createDescriptor("number_varray",
con);
int arrayValues[] = {34, 234, 432};
String model = "KIRSTIE";
oracle.sql.ARRAY array = new oracle.sql.ARRAY(arrayDesc, con,
arrayValues);
// Create a prepared statement for insertion of varray elements to
table rows
cstmt = con.prepareCall("{call sy_htproducts.p_test(?,?)}");
// Set the values to insert
((oracle.jdbc.driver.OracleCallableStatement)cstmt).setARRAY(2,
array);
((oracle.jdbc.driver.OracleCallableStatement)cstmt).setString(1,
model);
cstmt.execute();
} catch (SQLException e) {
System.out.println("test db error on varray = " + e.getMessage());
}
}
Received on Thu Aug 22 2002 - 23:41:00 CDT