How to check if an array contains a particular string?
contains, oracle, plsql, user-defined-types
Solution
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.
Problem
I have an array of strings. I want to check if a particular string is present in the array. ``` DECLARE TYPE v_array IS TABLE OF VARCHAR2(200); ais_array v_array; BEGIN ais_array := ('Lb1','Lb2','Lb3','Lb613'); IF 'Lb1' IN ais_array THEN dbms_output.put_line('found'); END IF; END; ``` The `IN` operator is not working. I tried doing a `select *` on the type and then using `IN` but that didn't work either. Any suggestions?