473,545 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
+ 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.CUST NUM=tbl_source. CUSTNUM_NEW WHERE tbl_target.CUST NUM = tbl_source_OLD ONLY getting the records from tbl_source.MAST ER=0


I can post the SQL I have tried tomorrow but thought it might be easier explained without.
Mar 1 '13 #1
1 2277
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
14041
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 the table A data with table B Oracle version is 8.1.7 Please advice which method is the fastest. i need to do it <30 mins
3
2562
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 employees. My database is all set up to provide the names and addresses of the companies and the list of employees of each company. I need help on...
4
3139
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. Here's the SQL I'm using... UPDATE Addresses SET Addresses.RawData = Trim$(); "Microsoft Access didn't update 2353 field(s) due to a type conversion...
5
3524
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 do the update the changed parentid in the child table fails to change. No error is given its just that the change is not written to the Database. ...
4
2451
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 with without messing with the live DB. Now, they would like to know if the changes they have made to the forked db can be merged back in to the live...
4
12272
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 to update/write into the table against Tax field the value that was calculated based on the field 'Gross'. Example, Gross * .02, the resulted value...
16
4861
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 restriction. Will a MERGE into this view "FACT" from tableA work?
4
1863
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 takes following arguments: t1 - table we would like to update t2 - table we would like to...
1
1369
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 Member's SSN", "Update a SSN") If SSNreplace = "" Then MsgBox "No Number Entered. Please Try Again", vbCritical, "Update a SSN"
6
2133
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 that users can open up, filter for their user id and choose one of four options for each individual record. I've built a query that runs based on a...
0
7669
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. ...
0
7926
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...
0
7773
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5987
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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...
0
3468
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...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
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 we have to send another system
1
1028
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.