How to check if an array contains a particular str

2019-02-06 14:21发布

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?

1条回答
一纸荒年 Trace。
2楼-- · 2019-02-06 15:11

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.

查看更多
登录 后发表回答