List loop list indx end loop end show list string
Term Fly Presents http://www.flyheart.com
END LOOP;
pl (book_rec.isbn || ' - ' ||
book_rec.author);
END;You need not take out "programmer's insurance": "Gee, I don't know if I need to declare that or not, so I'd better declare it." Instead, you make certain you understand how PL/SQL works and write appropriate code.
CTL-08: Scan collections using FIRST, LAST, and NEXT in loops.
CREATE OR REPLACE PACKAGE mycollection
IS
TYPE string_tt IS TABLE OF VARCHAR2 (2000) INDEX BY BINARY_INTEGER;PROCEDURE show (list_in IN string_tt);
FUNCTION eq (list1_in IN string_tt, list2_in IN string_tt) RETURN BOOLEAN
IS
retval BOOLEAN := TRUE;
indx PLS_INTEGER := list1_in.FIRST;
l_last1 PLS_INTEGER := list1_in.LAST;
BEGIN
WHILE retval
AND indx <= l_last1
LOOP
retval := list1_in (indx) = list2_in (indx);
indx := indx + 1;
END LOOP;
RETURN retval;
END eq;
END mycollection;
/At first glance, this seems fine. I throw together a test and am pleased with the results, as shown here: