java调用oracle存储过程的笔记
- 摘要:-------------------数据库-----------------------objectCREATEORREPLACETypeuser_objectIsObject(c_idNvarchar2(50),c_nameNvarchar2(30)}--typeCREATEORREPLACETypeType_userIsTableOfWeb_Fin_Clm_Type_vhl--procedureProcedurep_insert_user(userInfoType_user);-----
- 标签:笔记 ORA Java 过程 存储过程 Oracle 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);