INSERT INTO config.marc21_physical_characteristic_value_map (value,ptype_subfield,label) VALUES ('o',CURRVAL('config.marc21_physical_characteristic_subfield_map_id_seq'),'D-2');
INSERT INTO config.marc21_physical_characteristic_value_map (value,ptype_subfield,label) VALUES ('p',CURRVAL('config.marc21_physical_characteristic_subfield_map_id_seq'),'8 mm.');
INSERT INTO config.marc21_physical_characteristic_value_map (value,ptype_subfield,label) VALUES ('q',CURRVAL('config.marc21_physical_characteristic_subfield_map_id_seq'),'Hi-8 mm.');
+INSERT INTO config.marc21_physical_characteristic_value_map (value,ptype_subfield,label) VALUES ('s',CURRVAL('config.marc21_physical_characteristic_subfield_map_id_seq'),'Blu-ray');
INSERT INTO config.marc21_physical_characteristic_value_map (value,ptype_subfield,label) VALUES ('u',CURRVAL('config.marc21_physical_characteristic_subfield_map_id_seq'),'Unknown');
INSERT INTO config.marc21_physical_characteristic_value_map (value,ptype_subfield,label) VALUES ('v',CURRVAL('config.marc21_physical_characteristic_subfield_map_id_seq'),'DVD');
INSERT INTO config.marc21_physical_characteristic_value_map (value,ptype_subfield,label) VALUES ('z',CURRVAL('config.marc21_physical_characteristic_subfield_map_id_seq'),'Other');
--- /dev/null
+DO $FUNC$
+DECLARE
+ same_marc BOOL;
+BEGIN
+ -- Check if it is already there
+ PERFORM * FROM config.marc21_physical_characteristic_value_map v
+ JOIN config.marc21_physical_characteristic_subfield_map s ON v.ptype_subfield = s.id
+ WHERE s.ptype_key = 'v' AND s.subfield = 'e' AND s.start_pos = '4' AND s.length = '1'
+ AND v.value = 's';
+
+ -- If it is, bail.
+ IF FOUND THEN
+ RETURN;
+ END IF;
+
+ -- Otherwise, insert it
+ INSERT INTO config.marc21_physical_characteristic_value_map (value,ptype_subfield,label)
+ SELECT 's',id,'Blu-ray'
+ FROM config.marc21_physical_characteristic_subfield_map
+ WHERE ptype_key = 'v' AND subfield = 'e' AND start_pos = '4' AND length = '1';
+
+ -- And reingest the blue-ray items so that things see the new value
+ SELECT INTO same_marc enabled FROM config.internal_flag WHERE name = 'ingest.reingest.force_on_same_marc';
+ UPDATE config.internal_flag SET enabled = true WHERE name = 'ingest.reingest.force_on_same_marc';
+ UPDATE biblio.record_entry SET marc=marc WHERE id IN (SELECT record
+ FROM
+ metabib.full_rec a JOIN metabib.full_rec b USING (record)
+ WHERE
+ a.tag = 'LDR' AND a.value LIKE '______g%'
+ AND b.tag = '007' AND b.value LIKE 'v___s%');
+ UPDATE config.internal_flag SET enabled = same_marc WHERE name = 'ingest.reingest.force_on_same_marc';
+END;
+$FUNC$;