java调用oracle存储过程的笔记

-------------------数据库---------------------
--object
CREATE OR REPLACE Type user_object Is Object(
c_id Nvarchar2(50),
c_name Nvarchar2(30)
}

--type
CREATE OR REPLACE Type Type_user Is Table Of Web_Fin_Clm_Type_vhl

--procedure
Procedure p_insert_user(userInfo Type_user);

----------------------java调用-----------------------------
CallableStatement proc = conn.prepareCall(call);
ARRAY userArray=getFinClmDueInfoArray("user_object","Type_user",userDataList,conn);
proc.setArray(1, userArray);

--getFinClmDueInfoArray
StructDescriptor structdesc = new StructDescriptor(user_object.toUpperCase(), oracleconn);
if (userDataList != null && userDataList.size() > 0) {
int rows = userDataList.size();
STRUCT[] structs = new STRUCT[rows];
Object[] result = null;
for (int i = 0; i < rows; i++) {
UserVo userVO=userDataList.get(i);
result = new Object[2];
result[0] = userVo.getId();
structs[i] = new STRUCT(structdesc, oracleconn, result);
}

ArrayDescriptor arraydesc = new ArrayDescriptor(Type_user.toUpperCase(), oracleconn);
oracle.sql.ARRAY array = new ARRAY(arraydesc, oracleconn, structs);

你可能感兴趣的:(oracle,java)