From: Bill Erickson Date: Wed, 3 Jan 2018 20:26:02 +0000 (-0800) Subject: Force mismatched copy location batch updates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=08adafaba244b9da1a6ab7ad385fc5827a6c1f53;p=working%2FEvergreen.git Force mismatched copy location batch updates Temporarily disable the DB trigger preventing copy location updates during the nightly KCLS batch copy location / circ lib rescyn update. This primarily affects copies whose circ_lib does not match their call number owning lib (e.g. floating copies). Signed-off-by: Bill Erickson --- diff --git a/KCLS/utility-scripts/copy_loc_fix/fix_copy_locations.sql b/KCLS/utility-scripts/copy_loc_fix/fix_copy_locations.sql index e774f53f89..f1c5da9d9f 100644 --- a/KCLS/utility-scripts/copy_loc_fix/fix_copy_locations.sql +++ b/KCLS/utility-scripts/copy_loc_fix/fix_copy_locations.sql @@ -4,6 +4,8 @@ BEGIN; SET SESSION STATEMENT_TIMEOUT TO 0; +ALTER TABLE asset.copy DISABLE TRIGGER acp_location_fixer_trig; + UPDATE asset.copy a SET location = c.id FROM asset.copy_location b, asset.copy_location c @@ -20,3 +22,16 @@ AND c.name = b.name AND c.owning_lib = a.circ_lib; COMMIT; + +-- trigger has to be recovered after commit +ALTER TABLE asset.copy ENABLE TRIGGER acp_location_fixer_trig; + +\echo Find the number of copies remaining with location/lib mismatches + +SELECT COUNT(DISTINCT(acp.id)) AS remaining_mismatches +FROM asset.copy acp + JOIN asset.copy_location acpl1 ON (acpl1.id = acp.location) + JOIN asset.copy_location acpl2 + ON (acpl2.name = acpl1.name AND acpl2.owning_lib = acp.circ_lib) +WHERE NOT acp.deleted AND acp.circ_lib <> acpl1.owning_lib; +