0

While executing below code, getting error "Missing ON keyword" but I have already written ON clause. Please assist on cause.

merge into emp_temp s

using (select p.employee_id, p.salary, p.last_name,p.email, p.Hire_date, 
p.job_id from employees p
minus 
   select s.employee_id, s.salary, s.last_name,s.email, s.Hire_date, 
s.job_id from emp_temp s    
) EMPLOYEES p

ON (s.employee_id = p.employee_id)

when matched then
 update set s.salary = p.salary

when not matched then
insert 
(s.employee_id , s.salary,s.last_name,s.email,s.Hire_date, s.job_id) 
values
    (p.employee_id, p.salary, p.last_name,p.email, p.Hire_date, p.job_id);

1 Answer 1

1

It's coming from this line:

) EMPLOYEES p

You're setting the using clause's alias as EMPLOYEE, but that you're trying to re-alias that as just p. The error doesn't mean that you don't have an ON clause at all, just that it isn't where the parser is expecting to see it.

Since you refer to p later, you just want that single alias:

...
minus 
   select s.employee_id, s.salary, s.last_name,s.email, s.Hire_date, 
s.job_id from emp_temp s    
) p

ON (s.employee_id = p.employee_id)
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.