-
what is wrong with this query.
WHAT IS THE PROBLEM WITH THIS QUERY . WHERE I AM MAKING MISTAKE.
ANY BODY CAN HELP ME.
MERGE into copy_emp AS c
USING emp e
ON (c.empno = e.empno)
WHEN MATCHED THEN
UPDATE SET
c.empno = e.empno,
c.ename = e.ename,
c.job = e.job,
c.mgr = e.mgr,
c.hiredate = e.hiredate,
c.sal = e.sal,
c.comm = e.comm,
c.deptno = e.deptno
WHEN NOT MATCHED THEN
insert values (e.empno,e.name,e.job,e.mgr,e.hiredate,e.sal,e.comm,e.deptno);
WHEN I AM GOING TO RUN THIS CODE THE FOLLOWING ERROR ARAISE.
SQL> /
MERGE into copy_emp AS c
*
ERROR at line 1:
ORA-02012: missing USING keyword
THANKS
SOHAIL
-
Re: what is wrong with this query.
Have you tried removing the 'AS'?
Code:
MERGE INTO copy_emp c USING emp e
ON (c.empno = e.empno)
WHEN MATCHED THEN
UPDATE SET c.empno = e.empno,
c.ename = e.ename,
c.job = e.job,
c.mgr = e.mgr,
c.hiredate = e.hiredate,
c.sal = e.sal,
c.comm = e.comm,
c.deptno = e.deptno
WHEN NOT MATCHED THEN INSERT VALUES
( e.empno, e.name, e.job, e.mgr,
e.hiredate, e.sal, e.comm, e.deptno);
-
also remove updating the column on which join is made othewise merge will throw an error i.e.
MERGE INTO copy_emp c USING emp e
ON (c.empno = e.empno)
WHEN MATCHED THEN
UPDATE SET --- c.empno = e.empno,
c.ename = e.ename,
c.job = e.job,
c.mgr = e.mgr,
c.hiredate = e.hiredate,
c.sal = e.sal,
c.comm = e.comm,
c.deptno = e.deptno
WHEN NOT MATCHED THEN INSERT VALUES
( e.empno, e.name, e.job, e.mgr,
e.hiredate, e.sal, e.comm, e.deptno);
Experience is a hard teacher because she gives the test first, the lesson afterwards.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|