Here is what I need:
I have a LIST
of keys:
A
B
C
D
A TABLE keys
that contains:
A
B
**... and millions of other entries** ( but `NOT` `C` or `D` )
I want to see what is in the list AND
NOT IN the table AND list.
the expected output would be:
C
D
Since C
and D
are in the LIST
AND IN the TABLE
.
I have found examples of how to create a table of a type and wrap the list I just could not get the syntax correct by putting together disparate examples to get what I want and they all failed.
Here is what I am stuck on:
[42000][904] ORA-00904: "MISSING_KEY": invalid identifier
CREATE OR REPLACE TYPE MISSING_KEYS AS TABLE OF VARCHAR2(256);
SELECT missing_key
FROM TABLE (MISSING_KEYS('A','B','C','D'))
WHERE missing_key NOT IN (
SELECT key
FROM schema.keys
WHERE key IN ('A','B','C','D')
);
Best Answer
If you only need your list to have the keys (I'm using
minus
to find the difference between the two lists, you could modify it to useNOT IN
instead if you'd rather)If your list potentially needs to have multiple columns (i.e. a
key
and avalue
where you're looking for everything that doesn't match), you can create an object type that can have those additional columns and do