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 

Data purge in DB2 thru JCL

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


Joined: 24 Mar 2004
Posts: 2
Topics: 1
Location: USA

PostPosted: Thu Mar 25, 2004 8:27 pm    Post subject: Data purge in DB2 thru JCL Reply with quote

Hi,

How to purge previous years (ex:2000-2003) data from DB2 table thru JCL. I would like to keep the purged data in a dataset. Please advice me.

Regards
CCS
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Mar 26, 2004 6:09 am    Post subject: Reply with quote

ccs,

Even though ravi has provided the right links, I will post the solution as it can be done all in one single step.Try this unload jcl. It will first unload all the records where year is less than the current year. The delete statement will delete all the old records.


Code:

//STEP0100 EXEC PGM=IKJEFT01                 
//*                                         
//SYSTSPRT DD  SYSOUT=*,DCB=BLKSIZE=121     
//SYSPRINT DD  SYSOUT=*                     
//SYSTSIN  DD  *                             
DSN SYSTEM(XXXX)                           
RUN  PROGRAM(DSNTIAUL) -                   
      PLAN(DSNTIAUL)    -                   
      PARMS('SQL')      -                   
      LIB('XXXX.RUNLIB.LOAD')               
//SYSREC00 DD DSN=YOUR PURGED RECORDS,       
//            DISP=(NEW,CATLG,DELETE),       
//            UNIT=SYSDA,                     
//            SPACE=CYL,(X,Y),RLSE)                 
//SYSPUNCH DD SYSOUT=*                       
//SYSIN    DD  *                             
SELECT *                                     
     FROM                                   
     TABLE NAME
 WHERE YEAR_COL < CURRENT YEAR                               
             ;               
DELETE FROM                                   
     TABLE NAME
 WHERE YEAR_COL < CURRENT YEAR                               
             ;               
/*


Check this link for examples of unloading of the tables using DSNTIAUL

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNAPH11/APPENDIX1.3.1?DT=20010710165542

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
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Fri Mar 26, 2004 10:17 am    Post subject: Reply with quote

Kolusu,
How does the Utility handle Commits ? CCS may have to consider how the tables are being used to avoid -911's and also design appropriately for restart process. I would like to know if the utility takes a lock for the process are locks for each row being deleted ? thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Mar 26, 2004 10:34 am    Post subject: Reply with quote

Sureshkumar,

There is no commit involved in between the deletes while using the utility. After the succesful completion of the job, there is an implicit commit.So if he is worried about the dead locks then he can split the delete cards and apply commit in between.

For ex:
Code:

DELETE FROM                                   
     TABLE NAME
WHERE YEAR_COL = 2000;                               
COMMIT;               
DELETE FROM                                   
     TABLE NAME
WHERE YEAR_COL = 2001;                               
COMMIT;               
DELETE FROM                                   
     TABLE NAME
WHERE YEAR_COL = 2002;                               
COMMIT;               
DELETE FROM                                   
     TABLE NAME
WHERE YEAR_COL = 2003;                               


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
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Fri Mar 26, 2004 10:54 am    Post subject: Reply with quote

Kolusu,
Thanks for the reply, in effect you mean to say the 'max locks' does not apply to utilities. Just to have clarification. Thanks
Back to top
View user's profile Send private message
ccs
Beginner


Joined: 24 Mar 2004
Posts: 2
Topics: 1
Location: USA

PostPosted: Fri Mar 26, 2004 5:20 pm    Post subject: Reply with quote

Thanks for your concern Kolusu, Ravi and Suresh...

Regards
CCS
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