Somebody mailed me a list with codes, and I need to check whether each code does exist in an oracle 10 database table.
list looks something like:
code1, code2, code3
Of course for every item in the list i can do
select id from my_table where code = 'code1'.
But this would be time consuming, and not a very elegant. I would like to report back a list like:
code1 present
code2 X
code3 X
code4 present
I’m vaguely aware of oracle’s With statement, but I’m not sure how to use it with a list of values instead of a subquery.
The inverse can be achieved like this (see all codes from the database, and check whether they are in the list provided by your colleague):
If that won’t work for you, you can try this: