1 -- Copyright 2015, Equinox Software, Inc.
2 -- Author: Galen Charlton <gmc@esilibrary.com>
4 -- This program is free software; you can redistribute it and/or
5 -- modify it under the terms of the GNU General Public License
6 -- as published by the Free Software Foundation; either version 2
7 -- of the License, or (at your option) any later version.
9 -- This program is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- GNU General Public License for more details.
14 -- You should have received a copy of the GNU General Public License
15 -- along with this program; if not, write to the Free Software
16 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 \set ou_to_del ''''EXAMPLE''''
22 ALTER TABLE asset.copy DISABLE RULE protect_copy_delete;
23 ALTER TABLE asset.copy DISABLE TRIGGER audit_asset_copy_update_trigger;
24 CREATE INDEX tmp_import_as ON vandelay.import_item(imported_as);
28 DELETE FROM asset.copy_alert WHERE copy IN (
29 SELECT id FROM asset.copy WHERE circ_lib IN
30 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
35 DELETE FROM asset.opac_visible_copies WHERE copy_id IN (
36 SELECT id FROM asset.copy WHERE circ_lib IN
37 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
40 DELETE FROM asset.copy_part_map WHERE target_copy IN (
41 SELECT id FROM asset.copy WHERE circ_lib IN
42 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
46 DELETE FROM asset.stat_cat_entry_copy_map WHERE owning_copy IN (
47 SELECT id FROM asset.copy WHERE circ_lib IN
48 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
51 DELETE FROM asset.copy_note WHERE owning_copy IN (
52 SELECT id FROM asset.copy WHERE circ_lib IN
53 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
56 DELETE FROM vandelay.import_item WHERE imported_as IN (
57 SELECT id FROM asset.copy WHERE circ_lib IN
58 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del)
61 DELETE FROM asset.copy WHERE circ_lib IN
62 (SELECT (actor.org_unit_descendants(id)).id from actor.org_unit where shortname = :ou_to_del);
64 DELETE FROM asset.latest_inventory WHERE copy IN
65 (SELECT li.copy FROM asset.latest_inventory li LEFT JOIN asset.copy acp ON acp.id = li.copy WHERE acp.id IS NULL)
70 DROP INDEX vandelay.tmp_import_as;
71 ALTER TABLE asset.copy ENABLE RULE protect_copy_delete;
72 ALTER TABLE asset.copy ENABLE TRIGGER audit_asset_copy_update_trigger;