title: How to use MEMBER OF in PLSQL
body: <p>I have seen questions with this error, but either are calling external stores or trying with incompatible types or using a varray. So i setup a very simple example and still i can not make it work.</p>
  
  <pre><code>DECLARE 
  TYPE mytype IS TABLE OF VARCHAR2(4) INDEX BY PLS_INTEGER;
  mytable mytype;
  BEGIN
    mytable((mytable.COUNT+1)) := 'COD1';
    mytable((mytable.COUNT+1)) := 'COD2';
    mytable((mytable.COUNT+1)) := 'COD3';
    mytable((mytable.COUNT+1)) := 'COD4';  
    --IF 'COD1' MEMBER OF mytable THEN DBMS_OUTPUT.PUT_LINE('We have the code'); END IF;
    FOR i IN 1..mytable.COUNT LOOP
      DBMS_OUTPUT.PUT_LINE(mytable(i));
    END LOOP;
  END;
  </code></pre>
  
  <p>I get this if i run it:</p>
  
  <pre><code>COD1
  COD2
  COD3
  COD4
  </code></pre>
  
  <p>If i uncomment the IF (what i intend to use) i get this error.</p>
  
  <pre><code>PLS-00306: wrong number or types of arguments in call to MEMBER OF
  </code></pre>
  
  <p>Perhaps I am not using it correctly or something is wrong.</p>
  
  <p>I am trying to use that on a loop, I save the codes that I have used in the "array" then given one code I need to know if it was already used.
  My initial solution was to append to a string like ".COD1..COD2." and do a simple INSTR but does not seem right and I like arrays.
  I heard of that function (member of) which does what I wanted if only work as I believe it should.</p>
  
  <p>can you tell me How to use correctly, what i am doing wrong or how to solve my problem in a better way?</p>
  
  <p>Almost there...
  I change it to </p>
  
  <pre><code>-- Declare
  TYPE mytype IS TABLE OF VARCHAR2(4) INDEX BY VARCHAR(4);
  mytable mytype;
  -- Fill
  mytable('COD1') := 'COD1'; -- kind of redundant I only need the index
  -- The magic
  IF mytable.EXISTS('COD1')...
  </code></pre>
  
  <p>But I still feel that there should be a better way.</p>