Advertisement
roganhamby

Annual Cleanup - Abandoned Records w/ Deleted Holdings

Feb 27th, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* This is for deleting call number records and bib records where all their children (copies in the case of call numbers and
  2. call numbers in the case of bibs) have been deleted.  This is a bit more complicated than cleaning up those who have never
  3. had children.  Now, you may not need to do this.  If best cataloging practices are always followed you shouldn't have volumes or bibs floating out there after thier children are deleted but it can happen and here is how to clean it up. */
  4.  
  5. CREATE TABLE rogan.acn_delete AS
  6.     SELECT id FROM asset.call_number WHERE deleted IS FALSE AND id NOT IN
  7.     (SELECT DISTINCT(call_number) FROM asset.COPY WHERE deleted IS FALSE);
  8.  
  9. CREATE TABLE rogan.bib_delete AS
  10.     SELECT id FROM biblio.record_entry WHERE deleted IS FALSE AND date(create_date) < '2010-10-01' AND id NOT IN (
  11.     SELECT DISTINCT(record) FROM asset.call_number WHERE deleted IS FALSE);
  12.  
  13. update asset.call_number set deleted = TRUE where id in (select id from rogan.acn_delete);
  14.  
  15. update biblio.record_entry set deleted = true where id in (select id from rogan.bib_delete);
  16.  
  17. select count(id) from rogan.acn_delete;
  18.  
  19. select count(id) from rogan.bib_delete;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement