您能帮我编写JDBC程序来调用以下具有复杂输入类型的存储过程吗?
下面是我的存储过程定义
CREATE OR REPLACE TYPE inputObjects_t AS OBJECT (
serviceID VARCHAR2(7),
offerID VARCHAR2(7),
transactionID NUMBER
)
CREATE OR REPLACE TYPE inputArray_t IS VARRAY(100) OF inputObjects_t
PROCEDURE CheckObjectInput( pCustomerRef IN VARCHAR2,
pSubscriptionPS IN NUMBER,
pExpiryObjects IN inputArray_t,
pTransactionDtm IN DATE,
pTransactionID IN NUMBER);
PROCEDURE CheckObjectOutput( pCustomerRef IN VARCHAR2,
pSubscriptionPS IN NUMBER,
pExpiryObjects OUT inputArray_t,
pTransactionDtm IN DATE,
pTransactionID IN NUMBER);
最佳答案
如果您使用Oracle,请使用类OracleCallableStatement
。
有一种称为setSTRUCT
的方法。
一般示例:
OracleConnection conn = (...)
OracleCallableStatement cs = (OracleCallableStatement) conn.prepareCall(sql);
StructDescriptor sd = StructDescriptor.createDescriptor("MY_TYPENAME", conn);
Object[] attribs = new Datum[3];
attribs[0] = new CHAR("value1", charSet);
attribs[1] = new CHAR("value2", charSet);
CLOB clob2 = attribs[2] = new CLOB(conn);
STRUCT st = new STRUCT(sd, conn, attribs);
(...)
cs.setSTRUCT(n, st);
(...)
cs.execute()
关于java - JDBC程序调用具有复杂输入和输出的存储过程,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8837504/