1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

missing into statement

Discussion in 'SQL PL/SQL' started by SANKARIPR, Sep 8, 2012.

  1. SANKARIPR

    SANKARIPR Active Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    55
    MERGE Target AS T
    USING Source AS S
    ON (T.EmployeeID = S.EmployeeID)
    WHEN NOT MATCHED BY TARGET AND S.EmployeeName LIKE 'S%'
    THEN INSERT INTO(EmployeeID, EmployeeName) VALUES(S.EmployeeID, S.EmployeeName)
    WHEN MATCHED
    THEN UPDATE SET T.EmployeeName = S.EmployeeName
    WHEN NOT MATCHED BY SOURCE AND T.EmployeeName LIKE 'S%'
    THEN DELETE


    missing into error
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,346
    Likes Received:
    347
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    The error message is correct; please carefully look at a properly constructed MERGE statement:

    Code (SQL):
     MERGE INTO empm m
    USING emp e
    ON ( e.EMPNO = m.EMPNO )
    WHEN NOT matched THEN
    INSERT (m.empno, m.ename, m.job)
    VALUES (e.empno, e.ename, e.job)
    WHERE e.deptno=20
    WHEN matched THEN
    UPDATE SET job='janitor' WHERE ename='KING'
    DELETE WHERE (job='janitor');