Why FORALL doesn't throw value error when bind array is null?

Viewed 29

I have a sample code for FORALL

CREATE TABLE dummy (n NUMBER);
DECLARE
   TYPE numbers_t IS TABLE OF NUMBER;
   num   numbers_t := numbers_t ();
BEGIN

    FORALL indx IN NULL .. 10
   INSERT INTO dummy (n)
        VALUES (num (indx));

   DBMS_OUTPUT.put_line ('No error');

   EXCEPTION
   WHEN VALUE_ERROR
   THEN
      DBMS_OUTPUT.put_line ('Error');
END;

Output

    No error

Why FORALL does not throw value error like for loop statement when bind array's upper or lower bound is null?

1 Answers

There is no reason to throw an error simply because no DML operation will be performed in bulk with FORALL if there is no upper bound and lower bound of the bind array. I don't know Oracle's real intention behind this.

I have not seen any proper explanation for Why FOR LOOP throw Value error exception and FORALL doesn't. You can check out examples of FORALL to understand how it works. https://livesql.oracle.com/apex/livesql/file/content_CAV7T5WWK3ATEVKRBAPNOZ430.html https://oracle-base.com/articles/9i/bulk-binds-and-record-processing-9i

Related