MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Change all

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Martin
Beginner


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Mon Jun 19, 2006 12:04 am    Post subject: Change all Reply with quote

Hi ,

We need to change all 'X' to 'Y' in around 50 DB2 tables( which has around 30000 records each).

I know we can write SQL which will do the job. Wanted to know If there is any other ways of achieving this keeping in mind the performance and also time taken to do this job.

DB2 techies please help !

- Martin
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Mon Jun 19, 2006 2:49 am    Post subject: Reply with quote

Martin,

Is it that you are trying to update a column from char 'X' to 'Y' in 50 db2 tables ? Assuming there is a column called GROUP CHAR(1) in a table A and has value 'X' for some records.We need to change for all records the column to 'Y'.
Code:

UPDATE A SET GROUP = 'Y' would yied your results.

Can you please a sample of your requirement with your input and output ?
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
Martin
Beginner


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Tue Jun 20, 2006 12:48 am    Post subject: Reply with quote

shekar123,

Here's what I want: -

1) replace all occurance of 'X' to 'Y' in all the 50 db2 tables.

Could you please give the sql for the same?

Thanks,
Martin
Back to top
View user's profile Send private message
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Tue Jun 20, 2006 2:54 am    Post subject: Reply with quote

Well, you really have to code 50 SQL UPDATE statements.

If you would talk about more tables, say 500, I would suggest to generate the UPDATE statement via SELECT statements on the DB2 catalog. But with 50 Updates at hand, I wouldn't bother.

regards
Christian
Back to top
View user's profile Send private message
Martin
Beginner


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Tue Jun 20, 2006 7:46 am    Post subject: Reply with quote

CZerfas,

But the problem is the amount of data that needs to be changed in all the 50 tables... ( which has around 30000 records each).

- Martin
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jun 20, 2006 8:01 am    Post subject: Reply with quote

Martin,

If there is a primary key for the tables, you can split the update statement.

Update table set coln = 'Y' where primary_key <= 'value 1';

Update table set coln = 'Y' where primary_key > 'value 1' and primary_key <= 'value2'

...

Hope this helps....

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Martin
Beginner


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Tue Jun 20, 2006 1:46 pm    Post subject: Reply with quote

Kolusu,

We tried it But the time taken for completion is huge. Your approach will work only for 1 table at a time. I want to do a mass change in all the 50 tables at once.

Can any one give the syntax for using solution suggested by shekar123?

- Martin
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jun 20, 2006 1:56 pm    Post subject: Reply with quote

Quote:

We tried it But the time taken for completion is huge. Your approach will work only for 1 table at a time. I want to do a mass change in all the 50 tables at once.


You can code all the update statements as one sysin card and run it as a single job.

Quote:

Can any one give the syntax for using solution suggested by shekar123?


Shekhar also suggested the same update stmt one table at a time.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Tue Jun 20, 2006 3:09 pm    Post subject: Reply with quote

Martin,

Code all the update statements in a sysin control card and run the job.Try this code:

1.Change Proper DB2 Subsytem you are using
2.Give the proper dataset name for the RUNLIB.LOAD dataset which will have DSNTEP2 IBM Module
Code:

//STEP0100 EXEC PGM=IKJEFT01                                           
//SYSTSIN  DD  *                                                       
 DSN  SYSTEM(XXXX)                                                     
 RUN  PROGRAM(DSNTEP2)           -                                     
      PLAN(DSNTEP2)              -                                     
      LIB('XXXX.RUNLIB.LOAD')                                   
//SYSTSPRT DD  SYSOUT=*                                                 
//SYSPRINT DD  SYSOUT=*                                                 
//SYSIN    DD  DSN=SHEKAR.DB2.CARDS(MASSUPD)                                                     
/*                                                                     
//                                                                                                                           

SHEKAR.DB2.CARDS(MASSUPD)
UPDATE A SET GROUP = 'Y' WHERE CONDITION IS MET;               
UPDATE B SET GROUP = 'Y' WHERE CONDITION IS MET;               
.
.
.
.
TILL 50 TABLES

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group