/*
first create a PL/SQL object type and table type
*/
create or replace type SAMPLE_TYPE as object(
id number(34),
email varchar2(64),
info_value varchar2(255)
);
create or replace type SAMPLE_TABLE_TYPE as table of SAMPLE_TYPE;
//then in the java code
LogTrans app = new LogTrans();
int commit = 1;
Vector vector = new Vector();
Object[] attr = new Object[3];
attr[0] = (Object) new BigDecimal(8);
attr[1] = (Object) new String(“TEST@TEST.COM”);
attr[2] = (Object) new String(“TEST DATA”);
try
{
app.connect();
StructDescriptor structdesc = StructDescriptor.createDescriptor(“SAMPLE_TYPE”,app.con);
vector.add((Object)new STRUCT(structdesc, app.con, attr));
ArrayDescriptor arraydesc = ArrayDescriptor.createDescriptor(“SAMPLE_TABLE_TYPE”,app.con);
Object obj_array[] = vector.toArray();
ARRAY array = new ARRAY(arraydesc,app.con,obj_array);
CallableStatement cstm = app.con.prepareCall(“{ call PACKAGE.FUNCTION(?,?) }”);
((OracleCallableStatement)cstm).setARRAY(1, array);
cstm.setInt(2, 1);
cstm.execute();
System.out.println(“Please check database”);
}
catch(Exception e)
{
System.err.println(“dothis method exception: ” + e.getMessage());
}

Recent Comments