If you need to know what items listed in the IN
clause did not find a match in the table, you could take advantage of a user-defined or built-in collection - nested table or variable array. The example below uses built-in collection sys.odcinumberlist()
elements of which are of number data type:
/*sample of data */
with t1(col) as(
select level
from dual
connect by level <= 11
)
select s.column_value as missing_val
from t1 /* here you list the elements as you would using IN clause*/
right join table(sys.odcinumberlist(1,2,3,4,5,6,7,8,9,10, 70)) s
on (t1.col = s.column_value)
where t1.col is null
Result:
MISSING_VAL
------------
70
if elements in your list are of varchar
data type, the OdciVarchar2List()
collection can be used or ODCIDateList()
for elements of date
data type. You also free to create your own SQL type collection. For example:
create or replace type T_Type_Name is table of number