Forall

Description: FORALL transfers data from a PL/SQL collection to the specified table using collections. The following code example shows a procedure that accepts a nested table of book information and inserts the full contents of that collection (the binding array) into the book table. Note that this example also takes advantage of Oracle9i’s FORALL enhancement that allows the INSERT of a record directly into a table.

FORALL <index_name> IN <lower_boundary> .. <upper_boundary>
 
CREATE TYPE books_nt
  IS TABLE OF book%ROWTYPE;
/
CREATE OR REPLACE PROCEDURE add_books (
  books_in IN books_nt)
IS
BEGIN
  FORALL book_index
    IN books_in.FIRST .. books_in.LAST
    INSERT INTO book
       VALUES books_in(book_index);
   ...
END;

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.