DBMS_SQL.执行和批量更新 - 需要帮助
我有这个查询
从表中选择 col1、col2,其中 标准 = :criteria_var
DBMS_SQL 中使用特定查询来打开游标并绑定变量。然后,DBMS_SQL 函数将获取这些值,然后更新另一个表。但这是一次一排发生的。
我想使用 BULK FETCH INTO。我已阅读教程,但找不到任何可以使用 DBMS_SQL 进行 BULK FETCH INTO 的内容。
是否可以?如果是,那么如何?
I have this query
select col1, col2 from table where
critera = :criteria_var
The particular query was being used in DBMS_SQL to open cursor and BIND the variables. The values are then being fetched by DBMS_SQL functions which are then updating another table. but this is happening one row at a time.
I want to use BULK FETCH INTO. I have read the tutorials but i couldn't find anythign where i can use BULK FETCH INTO with DBMS_SQL.
is it possible? if yes, then how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 DBMS_SQL 包中的 BIND_ARRAY 过程来执行批量获取。有一个示例 DBMS_SQL 文档。
然而,除非特别需要使用 DBMS_SQL(并且首先假设动态 SQL 实际上是必要的),否则使用本机动态 SQL 似乎会更容易,即
如果您只是从此查询中获取数据然而,为了更新不同的表,让 Oracle 通过构建使用此查询获取多行的单个 UPDATE 语句来完成这项工作会更有效。像这样的东西
You can use the BIND_ARRAY procedure in the DBMS_SQL package to do a bulk fetch. There is an example of this in the DBMS_SQL documentation.
Unless there is a particular need to use DBMS_SQL, however, (and assuming dynamic SQL is actually necessary in the first place) it seems likely that it would be easier to use native dynamic SQL, i.e.
If you are just fetching the data from this query in order to update a different table, however, it would be more efficient to just let Oracle do that work by constructing a single UPDATE statement that used this query to fetch multiple rows. Something like