]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.bluray_vr_format.sql
cfd8c978b9a5bf61ad17dbd19244669f9ca0ffdc
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.bluray_vr_format.sql
1 DO $FUNC$
2 DECLARE
3     same_marc BOOL;
4 BEGIN
5     -- Check if it is already there
6     PERFORM * FROM config.marc21_physical_characteristic_value_map v
7         JOIN config.marc21_physical_characteristic_subfield_map s ON v.ptype_subfield = s.id
8         WHERE s.ptype_key = 'v' AND s.subfield = 'e' AND s.start_pos = '4' AND s.length = '1'
9             AND v.value = 's';
10
11     -- If it is, bail.
12     IF FOUND THEN
13         RETURN;
14     END IF;
15
16     -- Otherwise, insert it
17     INSERT INTO config.marc21_physical_characteristic_value_map (value,ptype_subfield,label)
18     SELECT 's',id,'Blu-ray'
19         FROM config.marc21_physical_characteristic_subfield_map
20         WHERE ptype_key = 'v' AND subfield = 'e' AND start_pos = '4' AND length = '1';
21
22     -- And reingest the blue-ray items so that things see the new value
23     SELECT INTO same_marc enabled FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc';
24     UPDATE config.internal_flag SET enabled = true WHERE name = 'ingest.reingest.force_on_same_marc';
25     UPDATE biblio.record_entry SET marc=marc WHERE id IN (SELECT record
26         FROM
27             metabib.full_rec a JOIN metabib.full_rec b USING (record)
28         WHERE
29             a.tag = 'LDR' AND a.value LIKE '______g%'
30         AND b.tag = '007' AND b.value LIKE 'v___s%');
31     UPDATE config.internal_flag SET enabled = same_marc WHERE name = 'ingest.reingest.force_on_same_marc';
32 END;
33 $FUNC$;