gpt4 book ai didi

java - 使用scala/java调用存储过程oracle参数数组

转载 作者:行者123 更新时间:2023-11-30 10:42:46 24 4
gpt4 key购买 nike

我有这段代码:

程序:

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

...

最佳答案

在 java 中,我使用了 oracle 过程,如:

CallableStatement cstmt = Connection.prepareCall("{CALL CmdtyStndrd.CmdtyStndrdProc(?)}");
cstmt.registerOutParameter(1, array_to_pass);
cstmt.execute();

而且有效。

关于java - 使用scala/java调用存储过程oracle参数数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37980683/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com