我想根据以下代码在数据库中插入一行
if table t has doesnot not have row with key X:
insert into t mystuff..
else
if update t set mystuff... where mykey=X if existingversion < NewVersion
我知道正常的合并可以如下使用
MERGE INTO (SELECT * FROM mytable WHERE status='active') old
USING (SELECT * FROM newtable) new
ON (new.id = old.id)
WHEN MATCHED THEN UPDATE SET old.data1=new.data1;
但是我如何处理我的合并条件更新?