DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: merge statement problem (ora - 30926)

  1. #1
    Join Date
    Jul 2006
    Posts
    96

    merge statement problem (ora - 30926)

    I want to use merge statment instead of the following insert
    statment.

    insert into temp_party(billno,grdt,gramt) select bill_no,vdate,sum(amt) from tran where nvl(crcode,'na') = '50303' and gr_no is not null
    and bill_no in(select billno from temp_party) group by bill_no,vdate

    this insert statement is working fine and is inserting rows.

    THE FOLLOWING MERGE STATMENT FAILS, WITH THE ERROR
    "UNABLE TO GET STABLE SET OF ROWS IN THE SOURCE TABLES".

    MERGE into temp_partyout A USING(select bill_no,vdate,sum(amt) AMT from
    tran where nvl(crcode,'na') = '50303' and gr_no is not null
    and bill_no in(select billno from temp_partyout) group by bill_no,vdate) B
    ON(A.BILLNO = B.BILL_NO)
    WHEN MATCHED THEN UPDATE SET A.GRDT = B.VDATE,A.GRAMT = B.AMT
    WHEN NOT MATCHED THEN
    INSERT(A.BILLNO,A.GRDT,A.GRAMT) VALUES(B.BILL_NO,B.VDATE,B.AMT)

    CAN ANY BODY PLZ GIVE THE SOLUTION OR CORRECT THE ABOVE MERGE
    STATMENT.

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Most likely table to be merged has multiple rows with same merge-key.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width