使用 CLOB 添加多个数据
我有这个外部 Oracle 存储过程,它采用 INTEGER、CLOB、VARCHAR 作为参数,并在执行时将记录插入到表中。这将使用由 JAVA + Spring 组成的 dao 层来调用。
我被要求使用相同的过程插入多条记录(1000s)。所以我正在考虑编写一个 pl/sql 块,它接受 String 或 Clob 并在调用该过程的循环中对值进行子字符串化。为此,我必须为每个记录附加一个带有删除表的字符串并将其作为参数传递,或者我可以从该字符串创建一个 CLOB 并将其作为参数传递。 例如:String param ="value1,value2,value3 | value1,value2,value3 | value1,value2,value3 ..etc"
我的问题是:
有没有比我更好的解决方案思考(因为我认为最好在数据库服务器内部循环它,而不是在 DAO 层循环并进行 1000 次数据库调用)?
如果我继续我的解决方案,是否会存在阻碍我的努力的限制,例如我可以传递到 pl/sql 块的数据大小?
I have this external oracle Stored Procedure which takes INTEGER,CLOB,VARCHAR as parameters, and which inserts a record to table upon executing. This will be called using a dao layer which consists of JAVA + Spring.
I have been asked to insert multiple records (1000s ) using the same procedure. so I am thinking of writing a pl/sql block which accepts either String or Clob and substrings the values in a loop which calls the procedure. For that I have to either append a String with delemeters for each record and pass it as a parameter or I could create a CLOB from that String and pass it as a parameter.
Eg:String param ="value1,value2,value3 | value1,value2,value3 | value1,value2,value3 ..etc"
My questions are:
Is there a better solution than what I am thinking (because I think it is better to loop it inside the DB server rather than looping in DAO layer and making 1000s of DB calls)?
If I go ahead with my solution will there be limitations which prevents my effort, such as size of the data that I can pass to the pl/sql block?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您参考这个问题:
Bulk insert from Java into Oracle
基本上,您应该执行一些批量操作,而不是数千个单独的操作。
I would refer you to this SO question:
Bulk insert from Java into Oracle
Basically, you should be doing a few bulk operations rather than thousands of individual ones.