473,414 Members | 1,677 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,414 software developers and data experts.

Merge Alternative

Ok, this should be simple, but I banging my head on this one:

Is there an Update statment that can accomplish the same as this Merged
statement?

MERGE INTO New_Table NT
USING Old_Table OT
ON OT.id = NT.id
WHEN MATCHED THEN
UPDATE
SET NT.Foo = OT.Foo

I'm on iSeries DB2, hence MERGE is not supported??

Tx

Chris

Mar 20 '06 #1
6 2972
Chris wrote:
Ok, this should be simple, but I banging my head on this one:

Is there an Update statment that can accomplish the same as this Merged
statement?

MERGE INTO New_Table NT
USING Old_Table OT
ON OT.id = NT.id
WHEN MATCHED THEN
UPDATE
SET NT.Foo = OT.Foo

I'm on iSeries DB2, hence MERGE is not supported??

UPDATE New_Table NT
SET NT.Foo = (SELECT OT.Foo FROM Old_Table OT WHERE OT.id = NT.id)
WHERE NOT EXISTS(SELECT 1 FROM Old_Table OT WHERE OT.id = NT.id)

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Mar 20 '06 #2
Sweet!! Thanks Chris

Mar 20 '06 #3
Serge,

Why *NOT* EXISTS? Looks like the update needs matching row ids, isn't
it?

-Eugene

Mar 21 '06 #4
Eugene F wrote:
Why *NOT* EXISTS? Looks like the update needs matching row ids, isn't
it?


Because otherwise the unmatched rows get set to null, which is not,
typically, what you had in mind.

--
Jonathan Leffler #include <disclaimer.h>
Email: jl******@earthlink.net, jl******@us.ibm.com
Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/
Mar 21 '06 #5
Eugene F wrote:
Serge,

Why *NOT* EXISTS? Looks like the update needs matching row ids, isn't
it?

Oops.. call it a test to see whether everyone is awake ;-)
WHERE EXISTS(....) is correct of course.
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Mar 21 '06 #6
Yeah, I noticed that too but I figured out what needed to be changed.
Tx again.

Chris

Mar 21 '06 #7

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

Similar topics

4
by: Tom Dauria | last post by:
What I am trying to do is write a resume into a word document from information in an Access database. I have been using bookmarks and inserting table results into the document and so far it's...
2
by: Aaron | last post by:
hello, i am perfoming a mail merge with the following code. Public Function MergeIt() Dim objWord As Object Set objWord = GetObject("C:\MyMerge.doc", "Word.Document") ' Make Word visible....
8
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...
3
by: svdh2 | last post by:
I have been looking at a problem the entire week in access, I have still not been able to find a solution. Hope that you could maybe tell where to look Concerns the link between Access and Word....
3
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...
4
by: John J. Hughes II | last post by:
Could someone explain how to merge the form menu with the mdi container window. The menu strip items on the form window merge but I either end up with a blank blue menu on the form or top list of...
2
by: cashdeskmac | last post by:
I have a database which I want to update with records from an XML file. The XML file MAY contain rows already present in the database. I was considering reading the contents of the database to...
16
by: UDBDBA | last post by:
Hi All: I need some clarification on a MERGE statement. The database is on V8 FP12 (AIX) 64bit. The source table is tableA. The target is a View "FACT" with UNION ALL because of the 512 Gig...
7
by: giladp1 | last post by:
I found Albert Kallal's great "Super easy Word Merge" code in his site at: http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html Thanks Albert so much for sharing this. I am looking...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
0
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...
0
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...

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.