From 533db70cdbe7589324585cbb56d5f4fb8d543984 Mon Sep 17 00:00:00 2001 From: Rogan Hamby Date: Mon, 17 Oct 2016 12:03:20 -0400 Subject: [PATCH] move call numbers from to be deleted org to undeleted org when the copy is at an undeleted org --- remove_ou_data/07_remove_volumes.sql | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/remove_ou_data/07_remove_volumes.sql b/remove_ou_data/07_remove_volumes.sql index 0447e2a..edea650 100644 --- a/remove_ou_data/07_remove_volumes.sql +++ b/remove_ou_data/07_remove_volumes.sql @@ -39,6 +39,14 @@ FROM asset.call_number WHERE owning_lib IN DELETE FROM asset.call_number WHERE owning_lib IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del); +UPDATE asset.call_number acn SET owning_lib = ac.circ_lib +FROM asset.copy ac +WHERE ac.call_number = acn.id +AND acn.owning_lib IN +(SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del) +AND acn.id IN +(SELECT call_number FROM asset.copy WHERE circ_lib NOT IN + (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)); COMMIT; -- 1.7.2.5