X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=remove_ou_data%2F07_remove_volumes.sql;h=71fc03a4c816f689f23228b47b4816d9d2f6b85b;hp=03f875420234d5c4d1c5884bf6e4d2f9c5fd21d2;hb=e327c4743fe61686222f0e3928a48ece319a1e3b;hpb=c919228a7234c1fdfa9f9cfbae245fc30731eb85 diff --git a/remove_ou_data/07_remove_volumes.sql b/remove_ou_data/07_remove_volumes.sql index 03f8754..71fc03a 100644 --- a/remove_ou_data/07_remove_volumes.sql +++ b/remove_ou_data/07_remove_volumes.sql @@ -16,9 +16,11 @@ -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. \set ou_to_del ''''EXAMPLE'''' +\set vol_del_table ORGUNIT_volume_bibs \set ECHO all \timing +DROP TABLE IF EXISTS esi.:vol_del_table; ALTER TABLE asset.call_number DISABLE RULE protect_cn_delete; ALTER TABLE asset.call_number DISABLE TRIGGER audit_asset_call_number_update_trigger; @@ -30,17 +32,22 @@ DELETE FROM asset.uri_call_number_map WHERE call_number IN ( (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del) ); -CREATE TABLE esi.albemarle_volume_bibs AS SELECT DISTINCT record +CREATE TABLE esi.:vol_del_table AS SELECT DISTINCT record FROM asset.call_number WHERE owning_lib IN (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del); 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); +DELETE FROM asset.call_number_prefix WHERE owning_lib IN +(SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del); + +DELETE FROM asset.call_number_suffix WHERE owning_lib IN +(SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del); COMMIT; ALTER TABLE asset.call_number ENABLE RULE protect_cn_delete; ALTER TABLE asset.call_number ENABLE TRIGGER audit_asset_call_number_update_trigger; -CREATE INDEX alb_vol_bib_idx ON esi.albemarle_volume_bibs(record); +CREATE INDEX org_vol_bib_idx ON esi.:vol_del_table(record);