MEMBER
Example
Section titled “Example”DECLARE TYPE num_tab IS TABLE OF NUMBER INDEX BY VARCHAR2 (64); nt1 num_tab;BEGIN nt1('one') := 1; nt1('two') := 2; nt1('three') := 3;
IF nt1.EXISTS('two') THEN DBMS_OUTPUT.PUT_LINE('Element exists'); END IF;
IF nt1.MEMBER('four') THEN DBMS_OUTPUT.PUT_LINE('Element does not exist'); END IF;
END;Output
Section titled “Output”Element existsExplanation
Section titled “Explanation”In the example code, num_tab is a hash-indexed collection of numbers indexed by varchar2. The EXISTS method is used to check if an index is part of the collection and returns true if it does exist, resulting in the print of ‘Element exists’. The MEMBER method is used to check if a value is a member of the collection. However, ‘four’ is not a member of the collection, thus the related output is not printed.