This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
kurs:merge_accountants [2010/05/18 11:15] 127.0.0.1 external edit |
kurs:merge_accountants [2010/10/30 14:56] mh |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <code> | ||
+ | delete from emp_copy where employee_id in (SELECT EMP_COPY.EMPLOYEE_ID | ||
+ | FROM EMP_COPY , DEPARTMENTS | ||
+ | WHERE ( (EMP_COPY.DEPARTMENT_ID = DEPARTMENTS.DEPARTMENT_ID) AND | ||
+ | (DEPARTMENTS.DEPARTMENT_NAME = 'IT') )) | ||
+ | |||
+ | select * from emp_copy where department_id = 60 | ||
+ | |||
+ | select count(*) from emp_copy | ||
+ | -- select /*+ first_rows */ * from employees | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | merge into emp_copy c | ||
+ | using employees e | ||
+ | on (e.last_name = c.last_name and e.first_name = c.first_name) | ||
+ | /* when matched then | ||
+ | update set salary = salary * 1.1 */ | ||
+ | when not matched THEN | ||
+ | insert ( | ||
+ | employee_id, | ||
+ | first_name, | ||
+ | last_name, | ||
+ | email, | ||
+ | hire_date, | ||
+ | job_id, | ||
+ | department_id, | ||
+ | salary | ||
+ | ) values ( | ||
+ | employees_seq.nextval, | ||
+ | e.first_name, | ||
+ | e.last_name, | ||
+ | e.email, | ||
+ | e.hire_date, | ||
+ | e.job_id, | ||
+ | e.department_id, | ||
+ | e.salary | ||
+ | ) | ||
+ | </code> | ||
+ | |||
<code> | <code> | ||
merge into accountants a | merge into accountants a |