Expanding on this question - Oracle Delete Rows Matching On Multiple Values, I need to use DELETE ... WHERE ... IN ...
from two lists, but I need to do it with text strings that are supplied by an an outside statement, not a SELECT
statement.
So for example I have these two strings:
'2810C000000635','2810C000000636','2810C000000637'
28006900,28006901,28006902
and I want to turn them into SQL.
DELETE FROM os_abp_classification WHERE (class_key, uprn) IN ('2810C000000635','2810C000000636','2810C000000637'),(28006900,28006901,28006902)
But running this gives me:
SQL Error: ORA-00920: invalid relational operator
This has been asked as Oracle multiple fields in Select IN Parameter - but the given answer doesn't work for me:
DELETE FROM os_abp_classification where (class_key, uprn) IN (
SELECT '2810C000000635','2810C000000636','2810C000000637' from DUAL
union
SELECT 28006900,28006901,28006902 from DUAL
)
ORA-00913: too many values
What's the format for such a query? Thanks
EDIT: I'm trying to replicate this functionality, but using the "where ... in" format instead because it's much faster (as discovered in Optimal way to DELETE specified rows from Oracle):
DELETE FROM os_abp_classification WHERE (class_key = '2810C000000635' and uprn = 28006900) or (class_key = '2810C000000636' and uprn = 28006901) or (class_key = '2810C000000637' and uprn = 28006902)