473,770 Members | 4,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MERGE syntax error

The statement:

merge into nullid.animals_ et_in t1 using is3.animals t2
on t1.sire_assoc=t 2.assoc and t1.sire_prefix= t2.prefix and
t1.sire_regnum= t2.regnum
when matched then update set t1.sire_bhid=t2 .bhid
when not matched then update set t1.sire_bhid=0
go

gets the error message:

Error: An unexpected token "when not matched then" was found following
"T1.SIRE_BHID=T 2.BHID". Expected tokens may include: "<merge_when_sp ec1>".

which I don't understand. I read the syntax diagrams and explanations
and thought that would be valid syntax. Any explanation or reference
would greatly appreciated. DB2 UDB V8.1.5 under Linux.
Nov 12 '05 #1
4 5325
In article <9q************ ***@fe05.lga>, Bob Stearns (rstearns1241
@charter.net) says...
The statement:

merge into nullid.animals_ et_in t1 using is3.animals t2
on t1.sire_assoc=t 2.assoc and t1.sire_prefix= t2.prefix and
t1.sire_regnum= t2.regnum
when matched then update set t1.sire_bhid=t2 .bhid
when not matched then update set t1.sire_bhid=0
go

gets the error message:

Error: An unexpected token "when not matched then" was found following
"T1.SIRE_BHID=T 2.BHID". Expected tokens may include: "<merge_when_sp ec1>".

which I don't understand. I read the syntax diagrams and explanations
and thought that would be valid syntax. Any explanation or reference
would greatly appreciated. DB2 UDB V8.1.5 under Linux.


You are not allowed to do an insert:

NOT MATCHED
Indicates the operation to be performed on the rows where the ON
search condition is false or unknown. Only INSERT or signal-statement
can be specified after THEN.
Nov 12 '05 #2
Gert van der Kooij wrote:
In article <9q************ ***@fe05.lga>, Bob Stearns (rstearns1241
@charter.net) says...
The statement:

merge into nullid.animals_ et_in t1 using is3.animals t2
on t1.sire_assoc=t 2.assoc and t1.sire_prefix= t2.prefix and
t1.sire_regnu m=t2.regnum
when matched then update set t1.sire_bhid=t2 .bhid
when not matched then update set t1.sire_bhid=0
go

gets the error message:

Error: An unexpected token "when not matched then" was found following
"T1.SIRE_BHID =T2.BHID". Expected tokens may include: "<merge_when_sp ec1>".

which I don't understand. I read the syntax diagrams and explanations
and thought that would be valid syntax. Any explanation or reference
would greatly appreciated. DB2 UDB V8.1.5 under Linux.

You are not allowed to do an insert:

NOT MATCHED
Indicates the operation to be performed on the rows where the ON
search condition is false or unknown. Only INSERT or signal-statement
can be specified after THEN.

... which when one thinks about it is the only option... How could DB2
update a row that it didn't find to begin with?

Cheers
Serge
Nov 12 '05 #3
Serge Rielau wrote:
Gert van der Kooij wrote:
In article <9q************ ***@fe05.lga>, Bob Stearns (rstearns1241
@charter.net) says...
The statement:

merge into nullid.animals_ et_in t1 using is3.animals t2
on t1.sire_assoc=t 2.assoc and t1.sire_prefix= t2.prefix and
t1.sire_regnum= t2.regnum
when matched then update set t1.sire_bhid=t2 .bhid
when not matched then update set t1.sire_bhid=0
go

gets the error message:

Error: An unexpected token "when not matched then" was found
following "T1.SIRE_BHID=T 2.BHID". Expected tokens may include:
"<merge_when_sp ec1>".

which I don't understand. I read the syntax diagrams and explanations
and thought that would be valid syntax. Any explanation or reference
would greatly appreciated. DB2 UDB V8.1.5 under Linux.

You are not allowed to do an insert:

NOT MATCHED
Indicates the operation to be performed on the rows where the ON
search condition is false or unknown. Only INSERT or signal-statement
can be specified after THEN.


.. which when one thinks about it is the only option... How could DB2
update a row that it didn't find to begin with?

Cheers
Serge

Doh!! I continue to think of 'not matched' meaning t1 not matched. It is
of course t2 which is not matched. Syntax like 'into not matched' and
'using not matched' (these choices are abominable, but it's late) would
be useful and cover all 3 cases.
Nov 12 '05 #4
Bob Stearns wrote:
Serge Rielau wrote:
Gert van der Kooij wrote:
In article <9q************ ***@fe05.lga>, Bob Stearns (rstearns1241
@charter.net) says...

The statement:

merge into nullid.animals_ et_in t1 using is3.animals t2
on t1.sire_assoc=t 2.assoc and t1.sire_prefix= t2.prefix and
t1.sire_regnum= t2.regnum
when matched then update set t1.sire_bhid=t2 .bhid
when not matched then update set t1.sire_bhid=0
go

gets the error message:

Error: An unexpected token "when not matched then" was found
following "T1.SIRE_BHID=T 2.BHID". Expected tokens may include:
"<merge_when_sp ec1>".

which I don't understand. I read the syntax diagrams and
explanations and thought that would be valid syntax. Any
explanation or reference would greatly appreciated. DB2 UDB V8.1.5
under Linux.

You are not allowed to do an insert:

NOT MATCHED
Indicates the operation to be performed on the rows where the ON
search condition is false or unknown. Only INSERT or signal-statement
can be specified after THEN.

.. which when one thinks about it is the only option... How could DB2
update a row that it didn't find to begin with?

Cheers
Serge


Doh!! I continue to think of 'not matched' meaning t1 not matched. It is
of course t2 which is not matched. Syntax like 'into not matched' and
'using not matched' (these choices are abominable, but it's late) would
be useful and cover all 3 cases.

DB2 has an (obvious) extension to the standard allowing you to add
predicates to MATCHED and NOT MATCHED. So you can indeed have more than
one UPDATE, DELETE and/or INSERT clause.
The ON-clause partitiones teh set into MATHCED and NOT MATCHED the
predicates sub-partitioned into the various phases.

Not sure if that covers what you're asking for.
Cheers
Serge
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4825
by: Karthik | last post by:
Hi, We have setup a publisher and a distributor in SQL 2000 running SP3. Alongwith this we have setup a merge replication agent and its running successfully inside the same network. I allow anonymous subscriptions and the merge publication works successfully for anonymous pull subscriptions also. Now i am trying to setup the same scenario to setup replication over the Internet using FTP. I have created a FTP site and given certain...
8
9524
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for each person for whom a mail merge letter is desired. The query reads address info from the table for each record where is true.
3
5587
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge document in Word; 2. opens the document and runs the merge process for the new data. I have managed to write the code to perform step 1 ok, but I'm having trouble with step 2. It opens the word document fine but does not perform the mail merge of...
3
3535
by: Bob Stearns | last post by:
We have a very poorly performing MERGE statement (an hour or more on tables of ~10000 and ~100000). This may require building temporary tables with appropriate indexes, but I thought I would ask your collective opinion. Would building a comprehensive index on nullid.angus_is improve this statement's performance? merge into (select * from nullid.ANGUS_IN where bhid is null) t1 using (select ta.*, ts.regnum as sire_regnum, td.regnum as...
4
18750
by: marklawford | last post by:
Hi guys, I'm getting the following error message when trying to run a MERGE statement I'm putting together. The syntax looks right to me But i must be missing something. The "srce" table reference runs fine on its own. SQL0969N There is no message text corresponding to SQL error "-788" in the
0
909
by: mayankaerry | last post by:
Hi, I am facing an error on calling Datset update method. Following is my scenario: There are Three Excel Files Test1.xls,Test2.xls and Test3.xls. There is data in Test1.xls as under: B
6
8997
by: amitabh.mehra | last post by:
I want to trap errors (RI errors), if any, that might turn up during merge in DB2. Is there some feature like the one in Oracle: MERGE INTO... WHEN MATCHED THEN UPDATE... WHEN NOT MATCHED THEN INSERT... LOG ERRORS INTO... I mean is there some LOG ERRORS INTO or an equivalent clause in case
1
6547
by: Esther Lane | last post by:
Hello! First off, many many thanks to Albert who wrote the Mail Merge code for MS Access I am using. It has been working beautifully for a few years. However, my client just (without notice!) upgraded from Access 2000 to Access 2007. Now that component is failing. The merge is building the data source file fine (text file named merge.888). I am providing an absolute path reference to the word file being used for the mail merge. ...
3
2409
by: subramanian100in | last post by:
Consider the following program: #include <cstdlib> #include <iostream> #include <set> #include <map> #include <algorithm> #include <iterator> #include <utility>
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.