2 -- copy location groups
6 INSERT INTO asset.copy_location (owning_lib, name) VALUES
11 (4, 'Children''s AV'),
26 INSERT INTO asset.copy_location (owning_lib, name, holdable) VALUES
27 (4, 'New Arrivals', FALSE);
29 -- non-holable, non-cirulcateable, non-visible
30 INSERT INTO asset.copy_location
31 (owning_lib, name, holdable, opac_visible, circulate) VALUES
32 (5, 'Display', FALSE, FALSE, FALSE),
33 (6, 'Display', FALSE, FALSE, FALSE),
34 (7, 'Display', FALSE, FALSE, FALSE);
37 -- copy location groups
39 INSERT INTO asset.copy_location_group (name, owner) VALUES ('Sys1 Fiction', 2);
41 INSERT INTO asset.copy_location_group_map (lgroup, location)
42 SELECT CURRVAL('asset.copy_location_group_id_seq'), id
43 FROM asset.copy_location WHERE owning_lib in (4, 5)
46 INSERT INTO asset.copy_location_group (name, owner) VALUES ('Sys2 Fiction', 2);
48 INSERT INTO asset.copy_location_group_map (lgroup, location)
49 SELECT CURRVAL('asset.copy_location_group_id_seq'), id
50 FROM asset.copy_location WHERE owning_lib in (6, 7)
53 -- evenly distribute the copies across all of the copy locations.
54 -- there's probably a more effecient way, but this gets the job done
57 DECLARE cur_loc INTEGER;
58 DECLARE cur_copy asset.copy%ROWTYPE;
60 cur_copy := evergreen.next_copy(0);
62 WHILE cur_copy.id IS NOT NULL LOOP
63 FOR cur_loc IN SELECT id FROM asset.copy_location ORDER BY id LOOP
64 UPDATE asset.copy SET location = cur_loc WHERE id = cur_copy.id;
65 cur_copy := evergreen.next_copy(cur_copy.id);
66 EXIT WHEN cur_copy.id IS NULL;