MERGE INTO impiegati dst
USING (
select a.employee_id, a.last_name || ‘ ‘ || first_name as nome, salary, a.department_id
from EMPLOYEES a
where a.department_id in (select department_id from departments)
) src ON (src.employee_id = dst.impiegato_numero)
WHEN NOT MATCHED
THEN INSERT(impiegato_numero,impiegato_nome,stipendio,dipartimento_id)
VALUES(src.employee_id, src.nome, src.salary, src.department_id )
WHEN MATCHED THEN UPDATE SET dst.dipartimento_id = src.employee_id;
Oracle: merge table
Settembre 19th, 2017 Nicola Tuccella