如何使用 Delphi/Ado 调用带有数组参数的 Oracle 过程进行批量插入?

发布于 2024-10-12 04:14:03 字数 101 浏览 6 评论 0 原文

我需要在 Oracle 数据库的单个表中添加数百万行。经过一些研究,我发现使用批量插入会提供更好的性能。 Delphi 程序读取并准备要插入的行。如何调用带有数组参数的过程以进行批量插入?

I need to add millions of rows in a single table in a Oracle database. After some research I found that using bulk insert would give a better performance. A Delphi program reads and prepares rows for insertion. How can I call a procedure with array parameters in order to do a bulk insert?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

宫墨修音 2024-10-19 04:14:03

对于 Oracle,您可以使用数组 DML 功能或直接路径 API。过去,Direct Path API 比 Array DML 快几倍,但在现代 Oracle 版本中,Array DML 仅比 Direct Path API 慢几个百分点。但数组 DML 比 Direct Path API 更加灵活并且限制更少!因此,我建议研究一下 Array DML 功能。

Delphi 标准数据访问库 - BDE、dbExpress、dbGo 不支持 Oracle Array DML amd Direct Path API。所以,你必须研究 3d 方库。我建议尝试 AnyDAC。它不仅为 Oracle 实现了数组 DML,还为所有受支持的 DBMS 实现了数组 DML。有关数组 DML 及其速度的更多信息,请查看文章:

With Oracle you can use the Array DML feature or Direct Path API. In past the Direct Path API was few times faster than Array DML, but in modern Oracle versions the Array DML is just few percents slower than Direct Path API. But the Array DML is far more flexible and has less restrictions than Direct Path API ! So, I will suggest to look into Array DML feature.

Delphi standard data access libraries - BDE, dbExpress, dbGo do not support Oracle Array DML amd Direct Path API. So, you have to look into 3d party libraries. I will suggest to try AnyDAC. It implements Array DML not only for Oracle, but for all supported DBMS's. For more information about Array DML and it speed check the articles:

忆梦 2024-10-19 04:14:03

我认为使用 ADO 无法做到这一点。从变体数组中进行批量插入是 Oracle 特定的,并且需要 Oracle 客户端中的功能; ADO 有意使其本质上相当通用。

您可以使用 Oracle Data Access 的第三方组件来执行此操作。有几种,但我个人有经验并且可以推荐用于批量数组插入的唯一一种是Direct Oracle Access (DOA)。

I don't think you can do that using ADO. Bulk insert from a variant array is Oracle-specific, and requires functionality in the Oracle client; ADO is intentionally fairly generic in nature.

You can do this using third-party components for Oracle Data Access. There are several, but the only one I have personal experience with and can recommend for the bulk array insert is Direct Oracle Access (DOA)..

蝶舞 2024-10-19 04:14:03

如果有这样的需求并且不能使用 SQL*Loader,最好的途径是直接使用 OCI(复杂...)或包装它的 Delphi 库。一个是 DOA(参见 White 答案),另一个是 ODAC。它们直接使用 OCI(ODAC 甚至可以直接与 Oracle 对话),并允许您利用高级 Oracle 功能。生成的代码可能不可移植,但速度很快。

If have such needs and can't use SQL*Loader the best path is to use OCI directly (complex...) or a Delphi library that wraps it. One is DOA (see White answer), another is ODAC. They use OCI directly (ODAC can even talk to Oracle directly) and allows you to exploit advance Oracle functionalities. The resulting code may not be portable, but it is fast.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文