我想使用输入执行存储过程(oracle) - 来自eclipselink的数字数组。
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("P_TEST2");
ReadQuery mquery = new DataReadQuery();
call.addNamedArgument("x");
call.addNamedOutputArgument("z");
mquery.setCall(call);
int [] x = {1,2,3};
Query query = ((JpaEntityManager)entityManager.getDelegate()).createQuery(mquery)
.setParameter("x", x);
DatabaseRecord record = (DatabaseRecord) query.getSingleResult();
System.out.println(record.get("z"));
程序本身
create or replace procedure p_test2(
x in numeric_array,
z out numeric
)
AS
BEGIN
FOR i IN x.first .. x.last
LOOP
INSERT INTO TEST2(ID,VALUE) VALUES (SEQ1.nextval,i);
END LOOP;
commit;
z := seq1.currval;
END;
/
但我认为它有问题,数组有问题。
需要你的帮助。