Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Oracle:ATUALIZAÇÃO DE CHAVE DUPLICADA


Oracle não tem on duplicate key update Use MERGE em vez de:
MERGE INTO my_table trg  
USING (SELECT 30 as question_id,0 as ug FROM DUAL
UNION ALL 
SELECT 31,1 FROM DUAL) src ON (src.question_id = trg.question_id)
WHEN NOT MATCHED THEN INSERT(question_id, ug) VALUES
(src.question_id, src.ug)
WHEN MATCHED THEN UPDATE
SET trg.ug = src.ug