Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

chrissharp123 Oct 11th, 2018 36 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. -- Period used to determine how long call numbers and bibs without
  2. -- copies stick around in the nontranscendental sources.
  3. \set period '''30 days'''::INTERVAL
  4.  
  5. -- CALL NUMBERS SANS COPIES/URIS
  6. WITH empty_acn AS (
  7. SELECT DISTINCT acn.id
  8. FROM asset.call_number acn
  9. LEFT JOIN asset.copy acp ON acp.call_number = acn.id AND NOT acp.deleted
  10. LEFT JOIN asset.uri_call_number_map aucnm ON aucnm.call_number = acn.id
  11. WHERE acn.id > 0 AND acp IS NULL AND aucnm IS NULL AND NOT acn.deleted AND acn.create_date < NOW() - :period
  12. )
  13. DELETE FROM asset.call_number
  14. WHERE id IN
  15. (SELECT id
  16.  FROM empty_acn);
  17.  
  18. -- BIBS WITH NO CALL NUMBERS
  19. WITH empty_bib AS (
  20. SELECT DISTINCT bre.id
  21. FROM biblio.record_entry bre
  22. LEFT JOIN asset.call_number acn ON acn.record = bre.id AND NOT acn.deleted
  23. WHERE bre.id > 0 AND acn IS NULL AND (bre.source IS NULL OR bre.source IN (1,2)) AND NOT bre.deleted AND bre.create_date < NOW() - :period
  24. )
  25. DELETE FROM biblio.record_entry
  26. WHERE id IN
  27. (SELECT id
  28.  FROM empty_bib);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top