我必须使用java:
将一些数据写入以下pl / sql过程I. PROCEDURE CREATE_MESSAGE (
P_BRM_WF_TYPE_TBL IN APPS_NE.XXG_BRM_WF_TYPE_TBL_OBJ, RETCODE OUT VARCHAR2,
ERROR OUT VARCHAR2)
IS
V_MSGID RAW (16);
V_ENQUEUE_OPTIONS DBMS_AQ.ENQUEUE_OPTIONS_T;
V_MESSAGE_PROPERTIES DBMS_AQ.MESSAGE_PROPERTIES_T;
V_NUM_HEADER_ID OE_ORDER_HEADERS_ALL.HEADER_ID%TYPE;
V_NUM_LINE_ID OE_ORDER_LINES_ALL.LINE_ID%TYPE;
V_NUM_ORG_ID OE_ORDER_HEADERS_ALL.ORG_ID%TYPE;
V_CHR_ROW_ID VARCHAR2 (200); -- XXEOM_ORDER_STATUSES.ROWID%TYPE;
V_EVENT_MSG APPS_NE.XXG_BRM_WF_TYPE_TBL_OBJ;
V_NUM_SUBS_STATUS XXEOM_ORDER_STATUSES.SUBSCRIPTION_STATUS%TYPE;
V_NUM_ERR_CTR NUMBER := 0;
BEGIN
RETCODE := 'SUCCESS';
ERROR := NULL;
V_EVENT_MSG := P_BRM_WF_TYPE_TBL;
----------------------------------------------------------------------------------------------------------------
II. XXG_BRM_WF_TYPE_TBL_OBJ
create or replace TYPE XXG_BRM_WF_TYPE_TBL_OBJ
AS OBJECT (C1 APPS_NE.XXG_BRM_WF_TYPE_TBL);
-----------------------------------------------------------------------------------------------------------------
III. create or replace TYPE XXG_BRM_WF_TYPE_TBL
AS VARRAY (20000) OF APPS_NE.XXG_BRM_WF_TYPE;
-----------------------------------------------------------------------------------------------------------------
IV. create or replace TYPE XXG_BRM_WF_TYPE AS OBJECT
(
ORDER_NUMBER NUMBER,
LINE_NUMBER NUMBER,
BU_ID NUMBER,
SUBSCRIPTION_DATE DATE,
STATUS VARCHAR2 (25),
DESCRIPTION VARCHAR2 (2000),
CONSTRUCTOR FUNCTION XXG_BRM_WF_TYPE
RETURN SELF AS RESULT
);
为此,我编写了如下代码:
Object[] p1obj = new Object[] { Integer.parseInt(serviceParams.get(1).toString()),
Integer.parseInt(serviceParams.get(2).toString()),
Integer.parseInt(serviceParams.get(3).toString()), "2017-11-12", "CREATED", "" };
final String typeName = "APPS_NE.XXG_BRM_WF_TYPE_TBL_OBJ";
final String typeTableName = "APPS_NE.XXG_BRM_WF_TYPE_TBL";
final StructDescriptor structDescriptor = StructDescriptor.createDescriptor(typeName.toUpperCase(), con);
final StructDescriptor structDescriptorTbl = StructDescriptor.createDescriptor(typeTableName.toUpperCase(), con);
final ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(typeTableName.toUpperCase(), con);
final ARRAY demoObjectsFromJava = new ARRAY(
arrayDescriptor,
con,
new STRUCT[]{
new STRUCT(structDescriptor, con, p1obj)
}
);
cstmt.setObject(1, structDescriptorTbl, Types.STRUCT);
cstmt.registerOutParameter(2, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(3, java.sql.Types.VARCHAR);
cstmt.execute();
con.commit();
Map<String, Object> map = new HashMap<String, Object>();
System.out.println(cstmt.getString(3));
updateSubscriptionResponse.put("RETCODE", cstmt.getString(3));
updateSubscriptionResponse.put("ERROR", cstmt.getString(4));
过程CREATE_MESSAGE输入XXG_BRM_WF_TYPE_TBL_OBJ类型,它是XXG_BRM_WF_TYPE_TBL的一个对象,它是XXG_BRM_WF_TYPE的一个varray。
我总是遇到不一致的java和sql类型错误。 我该如何解决?你能告诉我哪里出错吗?
答案 0 :(得分:0)
我找到了一种处理这些复杂的非原始表类型和对象的方法。 使用JDeveloper,我生成了模型类,这些模型类提供了setter和getter并使用ArrayList等Java集合映射到了这些表类型。