Given a list of identifiers, I need to identify those that are NOT in the Oracle database. For example, given a table:
my_table
+----+-------+
| ID | DATA |
+----+-------+
| 1 | Foo |
+----+-------+
| 3 | Bar |
+------------+
| 5 | Etc |
+------------+
... and given the list [1, 2, 3, 4], I need a list [2, 4].
I came up with this syntax using a sentence MINUS:
SELECT '1' as id FROM dual
UNION
SELECT '2' as id FROM dual
UNION
SELECT '3' as id FROM dual
UNION
SELECT '4' as id FROM dual
MINUS
SELECT id FROM my_table WHERE id IN ('1','2','3','4')
But that seems very awkward and will be messy, because in fact I will be dealing with hundreds of identifiers at a time. Is there a better syntax for getting a list of values than UNION syntax?
Sort of:
SELECT id FROM VALUES ('1', '2', '3', '4')
MINUS
SELECT id FROM my_table WHERE id IN ('1','2','3','4')
- . . , , . , , ?