Modify only the specific ROWs in DB2 table.

RDBMS from IBM and IBM's Hierarchical DBMS and Transaction Manager (IMS DC).
LearnMainframe
Registered Member
Posts: 36
Joined: Fri Jul 05, 2013 11:52 am

Modify only the specific ROWs in DB2 table.

Post by LearnMainframe »

Hello,Keeping in mind that LOAD REPLACE overwrites the entire table, and LOAD RESUME appends the data. Keeping this in mind, consider the scenario:Imagine a table with 100 rows, and I need to update 30 of them. My approach:
  1. Unload the entire table.
  2. Remove the rows that don’t need to be updated, keeping only the ones that require changes in the unloaded file.
  3. Make the necessary updates to the selected records. This does not alter the keys. 
  4. Reload the table using the modified file, ensuring that only the updated rows are affected.
Is there an option in the Load utility that supports this process? 
User avatar
zum13
Active Member
Posts: 135
Joined: Thu May 04, 2023 12:58 am

Re: Modify only the specific ROWs in DB2 table.

Post by zum13 »

The manual states: "If the table space already contains data, you can choose whether you want to add the new data to the existing data or replace the existing data." What you are attempting to do is partially replace the data. As far as I'm aware, the LOAD utility does not do that. You'd have to delete the rows you are replacing before loading the copied rows as added data. The alternative is to unload the table, edit the required rows (without removing the ones you're not updating), then reload the table replacing the existing rows.

Given that you are only updating 30 rows and that what you have described has all the hallmarks of a one-off corrective process, it may just be quicker and easier to use the UPDATE statement or use an editor utility. QMF has a feature for editing tables, as does IBM's File Manager/DB2 and Compuware's FileAid for DB2.
LearnMainframe
Registered Member
Posts: 36
Joined: Fri Jul 05, 2013 11:52 am

Re: Modify only the specific ROWs in DB2 table.

Post by LearnMainframe »

Thanks. I used QMF to update the table. Thank you for your reply. 
Post Reply Previous topicNext topic

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DB2 and IMS DB/DC”