You are on page 1of 2

Definition:

In Oracle PL/SQL, the FORALL statement is used to issue a series of static or dynamic
DML statements. The FO!LL is usually much faster than an e"ui#alent FO loo$. In some
cases $rocessin% may &e u$ to '( times as fast for o$erations such as I)S*T o$erations.
+hen usin% FO!LL each iteration of the loo$ must use #alues from one or more collections
in its ,!L-*S or +.** clauses. This re"uires some setu$ in ad#ance of usin% the
FO!LL statement.
The following restrictions apply when using FORALL:
/ 0ou cannot loo$ throu%h the elements of an associati#e array that has a strin% ty$e for
the 1ey.
/ 0ou cannot refer to the same collection in &oth the S*T clause and the +.**
clause of an -PD!T* statement 2ithin a FO!LL loo$.
/ The FO!LL statement can &e used only in ser#er3side $ro%rams, not in client3side
$ro%rams.
/ The I)S*T, -PD!T*, or D*L*T* statement must reference at least one collection.
! FO!LL statement that inserts a set of constant #alues in a loo$ 2ill raise an
e4ce$tion.
/ +hen s$ecifyin% an e4$licit ran%e, all collection elements in that ran%e must e4ist.
)on3e4istent elements 2ill $roduce an error.
/ +hen you use the INDICES OF or AL!ES OF clauses, all the collections
referenced in the DML statement must ha#e su&scri$ts matchin% the #alues of the
inde4 #aria&le.
/ If you use the SAE E"CE#TIONS clause, this error is treated li1e any other error
and does not sto$ the FO!LL statement.
/ Indi#idual record fields cannot &e referred to 2ithin DML statements called &y a
FO!LL statement. Instead, s$ecify the entire record 2ith the S*T O+ clause in an
-PD!T* statement, or the ,!L-*S clause in an I)S*T statement.
/ 5ollection su&scri$ts must use only the inde4 #aria&le 6such as i78 they cannot use an
e4$ression such as i$%.
/ The cursor attri&ute 9:-L;<O+5O-)T cannot &e assi%ned to other collections,
nor can it &e $assed as a $arameter to su&$ro%rams.

You might also like