If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Merge Into

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-10-06, 11:59
putts putts is offline
Registered User
 
Join Date: Jul 2003
Location: Frankenmuth, MI
Posts: 21
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....
Quote:
<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.
Reply With Quote
  #2 (permalink)  
Old 05-10-06, 13:19
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
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.
Reply With Quote
  #3 (permalink)  
Old 05-10-06, 15:25
putts putts is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On