473,473 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Update or merge field from 2nd table - DB2 iSeries

2 New Member
I am working on an iSeries v7r1 to consolidate customer accounts after de-deuplication. I am struggling with a fairly simply update to a single field from a value in another table.

tbl_target
CUSTNUM

tbl_source
CUSTNUM_NEW
CUSTNUM_OLD
MASTER

What I need to do is
UPDATE tbl_target.CUSTNUM=tbl_source.CUSTNUM_NEW WHERE tbl_target.CUSTNUM = tbl_source_OLD ONLY getting the records from tbl_source.MASTER=0


I can post the SQL I have tried tomorrow but thought it might be easier explained without.
Mar 1 '13 #1
1 2266
martyy
2 New Member
I was able to do the merge using the following code.

Expand|Select|Wrap|Line Numbers
  1. MERGE INTO tbltarget AS A
  2.  
  3. USING (
  4.  
  5. SELECT B.CUSTNUM_NEW, B.CUSTNUM_OLD, B.MASTER FROM tblsource B 
  6. ) AS B ON (
  7.  
  8. B.CUSTNUM_OLD = A.CUSTNUM AND B.MASTER='0'
  9.  
  10. )
  11.  
  12. WHEN MATCHED THEN
  13.  
  14. UPDATE SET 
  15. A.CUSTNUM = B.CUSTNUM;
Mar 1 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Raghu | last post by:
I have a temprary table with 5 million rows (A) which needs to be appended with 90 million row table (B). 60% of the rows of the 5mil rows already exist in the big table i need to update/merge...
3
by: Traci | last post by:
I need to do a mail merge letter from my database. The letter will be addressed to small companies and in the body of the letter I need to list employees of the company. There will be from 1 to 15...
4
by: MLH | last post by:
My table has an autonumber field and a text field named . Many records have unnecessary spaces padding the front and end of - at least, I think they're spaces. The look like spaces to me. ...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
4
by: Hought, Todd | last post by:
I have a bit of a dilemma, I'm fairly new to PG, and not quite sure how to do this: I have a DB that has been basically 'forked' - a copy of the original was made for a handful of users to play...
4
by: ormor | last post by:
Hi friends, I am new to MS Access. I have desiged a Form wherein I would like to update the field based on some calculation derived from the previous fields. How this can be done. I want...
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...
4
by: Farraige | last post by:
Hi I need your help... I am implementing the method that updates given table (table is represented as list of lists of strings) according to other table (some kind of merging)... This method...
1
by: Proaccesspro | last post by:
Trying to update a field in a table named CASE. How do I reference the particular field name?? The code is not working!! Dim SSNreplace As String SSNreplace = InputBox("Please enter the...
6
by: wellsfargouser | last post by:
Hey everyone, this is driving me crazy. I have a table which lists all the files users have on the server. This table is called risklist. It lists the pathname and size. The goal is to make a form...
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,...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.