Quero comparar valores ( VARCHAR2
com um valor da lista) usando IN
o operador. Por exemplo, o valor é A, os valores da lista são B e C. Os valores são
Código estático simples que funciona:
IF 'A' NOT IN ('B', 'C') THEN
DBMS_OUTPUT.PUT_LINE('Not');
ELSE
DBMS_OUTPUT.PUT_LINE('In');
END IF;
Código dinâmico que não funciona:
IF 'A' NOT IN ( SELECT COLUMN_VALUE FROM APEX_STRING.SPLIT('B:C', ':') ) THEN
DBMS_OUTPUT.PUT_LINE('Not');
ELSE
DBMS_OUTPUT.PUT_LINE('In');
END IF;
Obtendo um erro:
Error at line 39/48: ORA-06550: line 20, column 67:
PLS-00103: Encountered the symbol "(" when expecting one of the following:
. ) , @ with <an identifier>
<a double-quoted delimited-identifier> group having intersect
minus partition start subpartition union where connect sample
The symbol "having" was substituted for "(" to continue.
Não consigo entender onde está o erro. Na consulta SQL, código semelhante com IN
operador funciona.
Você não pode usar SELECT no operador IN. Você deve antes executar a consulta INTO uma variável e usar depois no IF TEST. Por exemplo, com função de contagem:
Obrigado.