我有这段代码:
程序:
CREATE OR REPLACE PACKAGE BODY PKG_ARRAY AS PROCEDURE PARAAJA_BULK(P_INPUTS IN PARAAJAARRAY)
IS BEGIN
FOR I IN 1 .. P_INPUTS.COUNT LOOP
INSERT INTO PARA_AJA
(FIELD1, FIELD2)
VALUES
(P_INPUTS(I).FIELD1, P_INPUTS(I).FIELD2);
END LOOP; END;
END;
和scala代码:
def spArray(name: List[person2],con:Connection) = Future[Boolean] { //supaya output jadi Future
DriverManager.registerDriver(new OracleDriver())
val conn = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxx)(PORT=xxxx))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=xxxx)))", "tesschema", "1234")
var callableStatement: CallableStatement = conn.prepareCall("call PKG_ARRAY.PARAAJA_BULK(?)")
val des = ArrayDescriptor.createDescriptor("PKG_ARRAY.PARAAJAARRAY", conn)
val array_to_pass = new ARRAY(des, conn, name)
callableStatement.setArray(1, array_to_pass)
callableStatement.execute()
}
但是,我有问题!!
无效的名称模式:PKG_ARRAY.PARAAJAARRAY
...
答案 0 :(得分:1)
在java中我使用oracle过程如:
CallableStatement cstmt = Connection.prepareCall("{CALL CmdtyStndrd.CmdtyStndrdProc(?)}");
cstmt.registerOutParameter(1, array_to_pass);
cstmt.execute();
它有效。
答案 1 :(得分:0)
PARAAJAARRAY应该是模式级别定义的类型,而不是在包级别定义的类型。尝试使用CREATE OR REPLACE TYPE PARAAJAARRAY创建类型为TABLE OF(您的记录对象类型)。