简体   繁体   English

具有多个OUT参数的Java存储过程批处理

[英]Java stored procedure batch with multiple OUT params

I'm using Oracle DB. 我正在使用Oracle DB。

And I need to call stored procedure sequentially for 1000 times. 而且我需要顺序调用存储过程1000次。 This stored procedure has several in params and out params. 此存储过程具有多个in参数和out参数。 Currently I'm doing it under one transaction. 目前,我正在一笔交易中进行此操作。 Simply using java's for-each loop and using Spring's StoredProcedure within of it. 只需使用java的for-each循环并在其中使用Spring的StoredProcedure。 This transaction takes about 4 seconds. 此交易大约需要4秒钟。 And it's not very cool. 而且不是很酷。 I need to speed-up this transaction time. 我需要加快这个交易时间。 Is there a way to do that? 有没有办法做到这一点?

Thanks in advance 提前致谢

Write a wrapper stored proc that calls all the other ones, inputting all the data to the wrapper proc as a hashmap, or something similar (see http://docs.oracle.com/cd/B19306_01/java.102/b14355/oraarr.htm#g1072333 ), storing the output in a cursor and returning it back out to Java. 编写一个包装存储的proc,该包装调用所有其他包装,将所有数据作为哈希图或类似内容输入到包装proc(请参见http://docs.oracle.com/cd/B19306_01/java.102/b14355/oraarr .htm#g1072333 ),将输出存储在游标中,然后将其返回给Java。 Call the wrapper from Java. 从Java调用包装器。 You then let the DB do all the heavy lifting and the entire job runs in one DB tx. 然后,您让数据库执行所有繁重的工作,并且整个工作在一个数据库TX中运行。

You could batch up the queries (using "in" if it is 1000 non predicable IDs) and return a cursor instead of a couple of out params each time? 您可以分批查询(如果有1000个不可预测的ID,请使用“输入”)并返回一个游标,而不是每次返回两个out参数? Of course, this won't be as easy if your in parameters differ per call. 当然,如果每次调用的in参数不同,这将不会那么容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM