I have a list of 100k ids in a file. I want to iterate through these ids:
for each id
, check if id
is in a table:
- If it is, update its
updated_date
flag - If not, add a new record
(id, updated_date)
I have researched and found MERGE
clause. The downside is, MERGE
requires the ids to be in a table. I am only allowed to create a temporary table if necessary.
Can anyne point me in the right direction? It must be a script that I can run on my database, not in code.
merge into MyTable x
using ('111', '222', all my ids) b
on (x.id = b.id)
when not matched then
insert (id, updated_date) values (b.id, sysdate)
when matched then
update set x.updated_date = sysdate;
EDIT: I am now able to use a temporary table if it's my only option.