I want to insert a row in a table if the keys are not in the table. If the keys are already in the table, I want to update two timestamps on the row as shown below:
Inputs to this routine include
lEarliest = TIMESTAMP
lLatest = TIMESTAMP
BEGIN
MERGE INTO mytable
USING dual ON (id1 = ? AND ...)
WHEN NOT MATCHED THEN
INSERT (...) VALUES (...)
WHEN MATCHED THEN
UPDATE SET earliest_timestamp = lEarliest where earliest_timestamp > lEarliest;
<--------- How can I add this second if statement to the Oracle MERGE clause? --------->
UPDATE SET latest_timestamp = lLatest where latest_timestamp < lLatest;
END;
/