How to check if an array contains a particular string?

旧时模样 提交于 2019-11-30 06:55:51
Egor Skriptunoff

Try member of condition:

IF 'Lb1' member of ais_array THEN
  dbms_output.put_line('found');
END IF;

Oracle introduced several set operators for working with collections in 10g. Please read the documentation to learn more.

MEMBER OF can only be used with nested tables. You're trying to use it on an associative array. You are going to get an error "wrong number or types of arguments in call to 'MEMBER OF' ".

This is how to use it:

    DECLARE  
   TYPE clientele IS TABLE OF VARCHAR2 (64);  

   client_list_12    clientele := clientele ('Customer 1', 'Customer 2');  
   client_list_13    clientele := clientele ('Customer 1', 'Customer 3');  

   client_list_133   clientele  
                   := clientele ('Customer 1', 'Customer 3', 'Customer 3');  

   client_list_empty clientele := clientele ();                          
BEGIN  
   IF 'Customer 1' MEMBER OF client_list_12  
   THEN  
      DBMS_OUTPUT.put_line ('Customer 1 is in the 12 list');  
   END IF;  

   IF 'Customer 2' NOT MEMBER OF client_list_13  
   THEN  
      DBMS_OUTPUT.put_line ('Customer 2 is not in the 13 list');  
   END IF;  

   DBMS_OUTPUT.put_line ('List 133 contains ' || CARDINALITY (client_list_133) || ' items');  

   IF client_list_empty IS EMPTY  
   THEN  
      DBMS_OUTPUT.put_line ('Client list is empty');  
   END IF;  

   IF client_list_133 IS NOT EMPTY  
   THEN  
      DBMS_OUTPUT.put_line ('Client list 133 is not empty');  
   END IF;  

END; 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!