In this example, there is a table Employee, and the table has columns EmployeeId and PhoneNumber.
If for the employee 123, we want to add her number into the table, or update her number when she is already in the table, we can use this command:
MERGE INTO Employee e
USING dual ON (e.EmployeeId = 123)
WHEN MATCHED THEN
WHEN MATCHED THEN
UPDATE SET e.PhoneNumber = '555-555-5555'
WHEN NOT MATCHED THEN
WHEN NOT MATCHED THEN
INSERT (e.EmployeeId, e.PhoneNumber)
VALUES (123, '555-555-5555');
No comments:
Post a Comment