I have the following query to insert a record if it does not already exists:
INSERT INTO "BMAN_TP1"."CELLS_TEXT" ("SET_ID", "CELL_ID")
VALUES (291565, 4256)
WHERE NOT EXISTS (
SELECT "SET_ID", "CELL_ID"
FROM "BMAN_TP1"."CELLS_TEXT"
WHERE ("SET_ID"=291565)
AND ("CELL_ID"=4256)
)
I know it can't work, because you can't use WHERE NOT EXISTS
clause with INSERT INTO VALUES
, but only with INSERT INTO SELECT (...)
.
Is there any other way to achieve this?
PLEASE NOTE:
I can't use Oracle's SELECT 291565, 4256 FROM DUAL
because it should also work with SQL Server.
I can't use MERGE
for the same reason.