Use variable.Last to get the last element
SQL> DECLARE 2 TYPE charTableType IS TABLE OF NUMBER INDEX BY VARCHAR2(64); 3 charTable charTableType; 4 stringTable charTableType; 5 howmany NUMBER; 6 which VARCHAR2(64); 7 8 BEGIN 9 charTable('A') := 1; 10 charTable('B') := 2; 11 howmany := charTable('A'); 12 13 stringTable('C') := 3; 14 stringTable('D') := 1000; 15 stringTable('D') := 1001; 16 which := stringTable.FIRST; 17 18 dbms_output.put_line(which); 19 which := stringTable.LAST; 20 dbms_output.put_line(which); 21 howmany := stringTable(stringTable.LAST); 22 23 dbms_output.put_line(howmany); 24 END; 25 / C D 1001 PL/SQL procedure successfully completed. SQL> SQL> SQL> SQL>