Code Listing 3: The poorly structured book_from_list function

CREATE OR REPLACE FUNCTION book_from_list (
   list_in IN book_tabtype,
   title_in IN book.title%TYPE)
RETURN book%ROWTYPE 
IS

   exit_function EXCEPTION;
BEGIN
   IF title_in IS NULL
   THEN
      RAISE exit_function;
   END IF;


   FOR indx IN list_in.FIRST .. list_in.LAST
   LOOP
      IF list_in(indx).title = title_in
      THEN
         RETURN list_in(indx);
      END IF;

   END LOOP;

   RAISE exit_function;

EXCEPTION
   WHEN exit_function THEN RETURN NULL;
END;