39 lines
1.2 KiB
Plaintext
39 lines
1.2 KiB
Plaintext
Using ``++FORALL i IN x.first ... x++``.last or ``++FORALL i IN 1 ... x.count++`` might fail when indexed collections are sparse as Oracle tries to access non-existent element(s) of x. ``++FORALL i IN INDICES OF x++`` syntax will always work including sparse collections. Thus using ``++FORALL i IN INDICES OF x++`` should be preferred as it makes code more robust and easier to review.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
FORALL i IN 1 .. l_tab.COUNT -- Non-Compliant
|
|
INSERT INTO forall_test VALUES l_tab(i);
|
|
|
|
FORALL i IN l_tab.first .. l_tab.last -- Non-Compliant
|
|
INSERT INTO forall_test VALUES l_tab(i);
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
FORALL i IN INDICES OF l_tab
|
|
INSERT INTO forall_test VALUES l_tab(i);
|
|
----
|
|
|
|
|
|
== See
|
|
|
|
* https://blogs.oracle.com/oraclemagazine/oracle-10g-adds-more-to-forall[Oracle 10g Adds More to FORALL]
|
|
* https://stevenfeuersteinonplsql.blogspot.com/2019/03/using-sparse-collections-with-forall.html[Using sparse collections with FORALL] - Steven Feuerstein
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
include::highlighting.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|