Reputation: 128
I want to check whether a value is a member of an array. I tried following sample code from How to check if an array contains a particular string?
DECLARE
TYPE v_array IS TABLE OF VARCHAR2(200);
ais_array v_array ;
BEGIN
ais_array := ('Lb1','Lb2','Lb3','Lb613');
IF 'Lb1' member of ais_array THEN
dbms_output.put_line('found');
END IF;
END;
/
But I am getting the following error:
ORA-06550: line 5, column 16:
PLS-00382: expression is of wrong type
Upvotes: 0
Views: 758
Reputation: 693
You should add the constructor call for initialization, try the code bellow
declare
type v_array is table of varchar2(200);
ais_array v_array;
begin
ais_array := v_array('Lb1', 'Lb2', 'Lb3', 'Lb613');
if 'Lb1' member of ais_array then
dbms_output.put_line('found');
end if;
end;
I've added the ais_array := v_array('Lb1', 'Lb2', 'Lb3', 'Lb613');
.
Upvotes: 2