使用 cx_Oracle 将长字符串数组(>4000 字节)传递到 Oracle (11gR2) 存储过程
我们需要使用 cx_Oracle 批量加载许多长字符串(>4000 字节,但<10,000 字节)。表中的数据类型是 CLOB。我们需要加载超过 1 亿个这样的字符串。一件一件地这样做会很糟糕。以批量方式执行此操作,即使用cursor.arrayvar() 将是理想的。但是,CLOB 不支持数组。 BLOB、LOB、LONG_STRING LONG_RAW 也没有。任何帮助将不胜感激。
We need to bulk load many long strings (>4000 Bytes, but <10,000 Bytes) using cx_Oracle. The data type in the table is CLOB. We will need to load >100 million of these strings. Doing this one by one would suck. Doing it in a bulk fashion, ie using cursor.arrayvar() would be ideal. However, CLOB does not support arrays. BLOB, LOB, LONG_STRING LONG_RAW don't either. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
非常规的建议,但由于您使用的是 11gR2,请查看 DBFS
从“加载”的角度来看,您只是复制文件,它们“显示”为 LOB。您可以使用内置 FTP 服务器执行类似的操作,但文件处理要容易得多。
然后,您只需编写一个过程,从 dbfs_content 视图中提取它们并将它们推送到您的过程。
另一个是,如果它们都低于 12,000 字节,请将它们分成三个部分,并将它们作为三个单独的 VARCHAR2(4000) 字符串进行处理,然后在 PL/SQL 端再次将它们连接起来。
Off the wall suggestion, but since you are on 11gR2 have a look at DBFS
From the 'load' point of view, you are just copying files and they 'appear' as LOBs. You can do a similar thing with the built-in FTP server but file handling is a lot easier.
You just then write a procedure that pulls them from the dbfs_content view and pushes them to your procedure.
The other though, is, if they are all under 12,000 bytes, split them into three parts and deal with them as three separate VARCHAR2(4000) strings and join them up again on the PL/SQL side.
为了完成足够好的事情,我们滥用了我在评论中提到的 CLOB。编码只用了不到 30 分钟,运行速度很快并且可以工作。
In the interest of getting shit done that is good enough, we did the abuse of the CLOB I mentioned in my comment. It took less than 30 minutes to get coded up, runs fast and works.