create or replace procedure p_1( pk in tb.id%type,col in tb.colname%type) asbegin if exists(select 1 from tb where id=pk) then update tb set colname=col where id=pk; else insert into tb values(pk,col) end if ; end;
MERGE INTO target_table D USING (SELECT col1, col2, col3_id... FROM source_table WHERE ...) S ON (D.pk_col = S.col1) WHEN MATCHED THEN UPDATE SET D.col2= s.col2... WHEN NOT MATCHED THEN INSERT (D.col2, D.col3) VALUES (S.col2, S.col3);
pk in tb.id%type,col in tb.colname%type)
asbegin
if exists(select 1 from tb where id=pk) then
update tb set colname=col where id=pk;
else
insert into tb values(pk,col)
end if ;
end;
USING (SELECT col1, col2, col3_id... FROM source_table
WHERE ...) S
ON (D.pk_col = S.col1)
WHEN MATCHED THEN UPDATE SET D.col2= s.col2...
WHEN NOT MATCHED THEN INSERT (D.col2, D.col3)
VALUES (S.col2, S.col3);