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.
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