Use count to determine the associative array, because the index-by TABLE statement is initialized, and the count statement will not cause an exception.
Cardinality is used to determine the nested table, because if the declared nested table is not initialized, using count will cause an exception, the minimum subscript of the nested table is not necessarily 1 (after the delete operation), so it cannot be determined by exists (1. You can only use cardinality.
Use exists (1) to judge varray, because if it is not initialized during varray declaration, using count will cause an exception, without the cardinality function, and the minimum subscript of varray is 1, therefore, you can use exists (1) to determine.
ExampleCode:
Declare
Type test_varray is varray (2) of varchar2 (10 );
Test_id_tab1 test_varray;
Type test_tab is table of varchar2 (10 );
Test_id_tab2 test_tab;
Type test_itab is table of varchar2 (10) index by binary_integer;
Test_id_tab3 test_itab;
CNT integer;
EXT Boolean;
Begin
Ext: = test_id_tab1.exists (1 );
If ext then
Dbms_output.put_line ('exist ');
Else
Dbms_output.put_line ('not exist ');
End if;
CNT: = cardinality (test_id_tab2 );
Dbms_output.put_line ('Count' | CNT );
CNT: = test_id_tab3.count;
Dbms_output.put_line ('Count' | CNT );
End;