How to Purge specified Records in a Repository and it's related Repositories
                    
                
                
                    
                        book
                        
Article ID: KB0071587
                        
                    
                    
                        calendar_today
                        
Updated On: 
                    
                 
                
                
                
                    
                
                    
                    
                    
                    
                        
                            
Description
                        
                        
                            This Articles provides the necessary scripts to Purge all the related records or Script to Purge specified Records in a Repository and its related Repositories
                         
                     
                    
                    
                        
                        
                    
                    
                        
                            
                                
Resolution
                            
                            
                                In the bin we have a utility datacleanup. You can use this utility to delete the root records.
eg:
datacleanup.bat -o record -rn <CATALOGNAME> -uf "/bin/qa_example.txt" -mn <USERNAME> -an <ENTERPRISENAME> -pwd <PASSWORD>
datacleanup.bat -o record -rn employee -uf "/bin/qa_example.txt" -mn a -an 920purge -pwd Admin123 .
In addtion if you want to delete hierarchy you need add additional parameter -dh y. This will delete all related records.
eg
datacleanup.bat -o record -rn <CATALOGNAME> -uf "/bin/qa_example.txt" -mn <USERNAME> -an <ENTERPRISENAME> -pwd <PASSWORD> -dh y
datacleanup.bat -o record -rn employee -uf "/bin/qa_example.txt" -mn a -an 920purge -pwd Admin123 -dh y
Suppose you have an hierarchy
     A
     |__B
        |__C
            |__D
        
        You choose B as your root and want to delete only hierarchy B-->C-->D then you can specify exclude relationship to not
        touch records in A using -exrel relationshipName eg: -exrel BtoA. if you have multiple exclude relationships then you can 
        add them with coma seperated -exrel relationshipName1,relationshipName2 eg:  -exrel BtoA,CtoD
        
datacleanup.bat -o record -rn <CATALOGNAME> -uf "/bin/qa_example.txt" -mn <USERNAME> -an <ENTERPRISENAME> -pwd <PASSWORD> -dh y -exrel relationshipName1,relationshipName2
datacleanup.bat -o record -rn employee -uf "/bin/qa_example.txt" -mn a -an 920purge -pwd Admin123 -dh y    -exrel BtoA,CtoD
Before deleting the hierarchy if you want to check what records are getting deleted then you can use addtionally -prev y. This will not 
delete the records but will just log the records identified for delete in purge log. Purgelog is located at <MQ_COMMON_DIR>\temp\year\month\date\hour
With this option records are not deleted but will just show preview.
eg:
datacleanup.bat -o record -rn <CATALOGNAME> -uf "/bin/qa_example.txt" -mn <USERNAME> -an <ENTERPRISENAME> -pwd <PASSWORD> -dh y -exrel relationshipName1,relationshipName2 -prev y
datacleanup.bat -o record -rn employee -uf "/bin/qa_example.txt" -mn a -an 920purge -pwd Admin123 -dh y    -exrel BtoA,CtoD -prev y
datacleanup.bat -o record -rn <CATALOGNAME> -uf "/bin/qa_example.txt" -mn <USERNAME> -an <ENTERPRISENAME> -pwd <PASSWORD> -dh y -prev y
datacleanup.bat -o record -rn employee -uf "/bin/qa_example.txt" -mn a -an 920purge -pwd Admin123 -dh y    -prev y
NOTE:1.As this script is for purge.  Please note purge is a hard/permanent delete. i.e. It will delete the data from the database as well as UI. We cant do rollback once we do purge. Please do it in a lower environment and avoid trying in production.
2.The input file path can be relative to MQ_HOME,user.home or absoulte path.
Input in file can be 
productkeyid:
eg:
ID
1001 
productid : if productidextension is not used
eg:
PRODUCTID
B 
productid,productidextension
eg:
PRODUCTID,PRODUCTIDEXT
B,B
 
                            
                         
                        
                    
                        
                            
                                
Issue/Introduction
                            
                            
                                Purge specified Records in a Repository and it's related Repositories or all the related records
                            
                         
                        
                    
                        
                            
                                
Additional Information
                            
                            
                                Purge, Delete, Related Records, Datacleanup
                            
                         
                        
                    
                    
                
                    
                        
                            Was this article helpful?
                        
                        
                            
                                thumb_up
                                Yes
                            
                            
                                thumb_down
                                No