ORACLE批量绑定FORALL与BULK COLLECT
发布时间:2020-12-12 14:45:26 所属栏目:百科 来源:网络整理
导读:FORALL与BULK COLLECT的使用方法: 1.使用FORALL比FOR效率高,因为前者只切换一次上下文,而后者将是在循环次数一样多个上下文间切换。 2.使用BLUK COLLECT一次取出一个数据集合,比用游标条取数据效率高,尤其是在网络不大好的情况下。但BLUK COLLECT需要
FORALL与BULK COLLECT的使用方法:
1.使用FORALL比FOR效率高,因为前者只切换一次上下文,而后者将是在循环次数一样多个上下文间切换。 2.使用BLUK COLLECT一次取出一个数据集合,比用游标条取数据效率高,尤其是在网络不大好的情况下。但BLUK COLLECT需要大量内存。 例子:
select into 中使用bulk collect DECLARE fetch into 中使用bulk collect CURSORc1IS To maximize performance,rewrite your programs as follows: a. If an INSERT,UPDATE,or DELETE statement executes inside a loop and References collection elements,move it into a FORALL statement. b. If a SELECT INTO,FETCH INTO,or RETURNING INTO clause references a Collection,incorporate the BULK COLLECT clause. c. If possible,use host arrays to pass collections back and forth between your Programs and the database server. d. If the failure of a DML operation on a particular row is not a serious problem,Include the keywords SAVE EXCEPTIONS in the FORALL statement and report Or clean up the errors in a subsequent loop using the %BULK_EXCEPTIONS Attribute. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |