Created
September 1, 2016 13:46
-
-
Save stompro/5dc3db589659d7f3fd781810bf0c2f63 to your computer and use it in GitHub Desktop.
Fix incorrect magazine merge Evergreen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Accidentally merged readers digest large print into regular readers digest. | |
-- Look up deleted bib records | |
select * | |
from | |
biblio.record_entry bre | |
where | |
marc~'Readers Digest' | |
and bre.deleted=true | |
; | |
--Volumes to fix | |
select string_agg(acn.id::text,',') from | |
asset.call_number acn | |
-- join asset.copy acp on acp.call_number=acn.id | |
where | |
acn.record in (188975,172139,158046,143665) | |
and acn.deleted=false | |
-- group by acn.id; | |
--Copies to fix. | |
-- Copies to fix | |
select aach.id,aach.call_number | |
from | |
auditor.asset_copy_history aach | |
where | |
aach.call_number in (6714748,6982718,6971944,6931183,6912798,6878783,6978608,6837132,6783687,6737332,6692320,6640744,7011044,7022195,7003565) | |
and aach.audit_time='2016-08-31 14:54:40.775623-05'::timestamp | |
and aach.deleted=false | |
order by audit_id desc | |
; | |
--Create table to hold old volume and part mapping. | |
-- parts to fix | |
create table larl_temp.readers_digest_large_print | |
as | |
select aach.id copyid,aach.call_number callnumid, bmp.label | |
from | |
auditor.asset_copy_history aach | |
join asset.copy_part_map acpm on aach.id=acpm.target_copy | |
join biblio.monograph_part bmp on bmp.id=acpm.part | |
where | |
aach.call_number in (6714748,6982718,6971944,6931183,6912798,6878783,6978608,6837132,6783687,6737332,6692320,6640744,7011044,7022195,7003565) | |
and aach.audit_time='2016-08-31 14:54:40.775623-05'::timestamp | |
and aach.deleted=false | |
order by audit_id desc | |
; | |
-- Update volume | |
update asset.copy acp | |
set call_number=rd.callnumid | |
from | |
larl_temp.readers_digest_large_print rd | |
where | |
rd.copyid=acp.id | |
returning acp.id,acp.call_number | |
; | |
--Move to part | |
select evergreen.larl_moveto_part(rd.copyid,rd.label) | |
from | |
larl_temp.readers_digest_large_print rd | |
; | |
-- bibs (188975,172139,158046,143665) | |
-- | |
select * | |
from | |
asset.copy acp | |
join asset.call_number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment