473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

merge statement - why it is failing

MERGE INTO MyTable as nd USING
(with tex (ID, acc_num) as ( values ('1','acc232'), ('2','acc8993'),
('3','acc543') )
select ID, acc_num from tex
) as T
on nd.id = T.ID
WHEN NOT MATCHED THEN
INSERT (ID) VALUES (T.ID) ;

Error message:
"
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0104N An unexpected token "as" was found following "th tex (ID,
acc_num)".
Expected tokens may include: "JOIN". SQLSTATE=42601

SQL0104N An unexpected token "as" was found following "th tex (ID,
acc_num)". Expected tokens may include:
"JOIN ".
"

What am I doing wrong..?

Thanks,

Oct 2 '07 #1
1 2711
an*************@gmail.com wrote:
MERGE INTO MyTable as nd USING
(with tex (ID, acc_num) as ( values ('1','acc232'), ('2','acc8993'),
('3','acc543') )
select ID, acc_num from tex
) as T
on nd.id = T.ID
WHEN NOT MATCHED THEN
INSERT (ID) VALUES (T.ID) ;

Error message:
"
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0104N An unexpected token "as" was found following "th tex (ID,
acc_num)".
Expected tokens may include: "JOIN". SQLSTATE=42601

SQL0104N An unexpected token "as" was found following "th tex (ID,
acc_num)". Expected tokens may include:
"JOIN ".
"

What am I doing wrong..?
The WITH clause isn't supported in subqueries.
But why so complicated?
MERGE INTO MyTable as nd
USING (values ('1','acc232'), ('2','acc8993'),
('3','acc543') ) AS T(ID, acc_num)
....

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Oct 2 '07 #2

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

Similar topics

3
by: Jim | last post by:
I have a situation with a 6 server setup whereby merge agents will not run if other merge agents are alreay running. Basically we have a 5 laptop, one tower config with the tower being the...
1
by: rebeaj | last post by:
Merge SQL statement will not compile. Can anyone help me out? Create Or Replace Procedure P_pvt_merge As Begin Merge Into Employees2 B Using ( Select Employee_id, First_name, Last_name,...
4
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...
16
by: Sam Durai | last post by:
Hello, I need to merge a small table (of rows less than 100,sometimes even 0 rows) to a big table (of rows around 4 billion). I used the PK of the big table as merge key but merge does a table scan...
5
by: melentina | last post by:
Hello, I'm trying to use MERGE statement in a procedure, please see the code below: procedure gen_nou (p_data date) is v_atribut_id number; begin v_atribut_id=100;
1
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!)...
1
by: UDBDBA | last post by:
Hi, If someone can clarify this, it would be of great help! We have a merge, which is written *only* to update the target table. but the access plan shows branches with inserts and deletes on...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
7
by: Henry J. | last post by:
I got a dumb question on the merge statement. I read the following example of merge statement at the IBM page:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.