This process has two forms. The TRIM removes an element from the end of the collection. The TRIM(n) removes the n elements from the end of the collection. For e.g. this statement removes all the last three elements from the nested table courses:
If n is bigger than COUNT, then TRIM(n) raises SUBSCRIPT_BEYOND_COUNT.
TRIM operates on the internal size of the collection. Therefore, if TRIM encounters deleted elements, then it includes them in its tally. Consider the example shown below:
TYPE CourseList IS TABLE OF VARCHAR2(10);
courses := CourseList('Biol 4412', 'Psyc 3112', 'Anth 3001');
courses.DELETE(courses.LAST); -- delete element 3
/* At this point, COUNT equals 2, the number of valid
elements remaining. So, you might expect the next
statement to blank the nested table by trimming
elements 1 and 2. Instead, it trims valid element 2
and the deleted element 3 as TRIM includes deleted
elements in its tally. */
DBMS_OUTPUT.PUT_LINE(courses(1)); -- prints 'Biol 4412'
In normal, do not depend on the interaction between the TRIM and DELETE. It is better to treat nested tables such as fixed-size arrays and use only DELETE, or to treat them like the stacks and use only TRIM and EXTEND.
The PL/SQL does not keep placeholders for the trimmed elements. As a result, you cannot replace a trimmed element just by assigning it a new value.