DECLARE
string_valor VARCHAR2(100);
lista_array dbms_utility.lname_array;
contador binary_integer;
BEGIN
SELECT t.campo_a INTO string_valor
FROM tabela t
WHERE t.campo_cod = 1;
dbms_utility.comma_to_table
(
list => regexp_replace(string_valor,'(^|,)','x')
, tablen => contador
, tab => lista_array
);
FOR i in 1 .. l_count LOOP
dbms_output.put_line( substr(lista_array(i),2) );
END LOOP;
END;
This code works perfectly, what it does is to get a VARCHAR variable with values '2,3,5,9' for example and separate them into a vector of numbers, so that this need? So that I can compare, using NOT IN, each element of ARRAY with a field of NUMBER inside the WHERE clause.
The problem is how I can call it in the Where clause, using NOT IN:
SELECT ... FROM tabela t
WHERE campo_exemplo_1 > 0
AND campo_exemplo_2 <> campo_exemplo_4
AND campo_exemplo_3 NOT IN ( ARRAY AQUI??? )