Results 1 to 3 of 3

Thread: Merge Into

  1. #1
    Join Date
    Jul 2003
    Location
    Frankenmuth, MI
    Posts
    21

    Unanswered: Merge Into

    I'm trying to do the following....

    Code:
    CREATE TABLE NEW_SAMPLES(
    ID INT GENERATED ALWAYS AS IDENTITY(START WITH 1, INCREMENT BY 1),
    SAMPLE_TEXT VARCHAR(100),
    PRIMARY KEY(ID))
    GO
    
    CREATE TABLE MAIN_SAMPLES(
    ID INT GENERATED ALWAYS AS IDENTITY(START WITH 1, INCREMENT BY 1),
    SAMPLE_TEXT VARCHAR(100),
    PRIMARY KEY(ID))
    GO
    
    
    INSERT INTO NEW_SAMPLES (SAMPLE_TEXT) VALUES ('Testing 1,2,3')
    GO
    
    MERGE INTO MAIN_SAMPLES MS USING (SELECT ID,SAMPLE_TEXT FROM NEW_SAMPLES) NS ON MS.ID = NS.ID
    WHEN MATCHED THEN UPDATE SET SAMPLE_TEXT = NS.SAMPLE_TEXT
    WHEN NOT MATCHED THEN INSERT (SAMPLE_TEXT) VALUES (NS.SAMPLE_TEXT)
    But I keep getting the following message on the MERGE Statement....
    <eb1>SQL0104N An unexpected token "MS" was found following "MERGE MAIN_SAMPLES ". Expected tokens may include: "JOIN <joined_table>". SQLSTATE=42601

    State:42601,Native:-104,Origin:[IBM][CLI Driver][DB2/NT]</eb1>
    Can any of you fine folks tell me why I'm getting that message that doesn't even seem to make sense

    Thanks In Advance.

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    IIRC, MERGE was not available until V8 FP 4

    I'm sorry, if this doesn't explain your problem ... As you have not mentioned your version info, this is the first thing that comes to my mind

    HTH

    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jul 2003
    Location
    Frankenmuth, MI
    Posts
    21
    ahhh...nope....that explains it.

    I think we are still on 7.2 as we have not yet had a "business-relevant" need to upgrade.

    Thanks.

Posting Permissions

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