]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.vr_format_value_maps.sql
TPac: Advanced Search Config
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.vr_format_value_maps.sql
1 CREATE OR REPLACE FUNCTION config.update_coded_value_map(in_ctype TEXT, in_code TEXT, in_value TEXT, in_description TEXT DEFAULT NULL, in_opac_visible BOOL DEFAULT NULL, in_search_label TEXT DEFAULT NULL, in_is_simple BOOL DEFAULT NULL, add_only BOOL DEFAULT FALSE) RETURNS VOID AS $f$
2 DECLARE
3     current_row config.coded_value_map%ROWTYPE;
4 BEGIN
5     -- Look for a current value
6     SELECT INTO current_row * FROM config.coded_value_map WHERE ctype = in_ctype AND code = in_code;
7     -- If we have one..
8     IF FOUND AND NOT add_only THEN
9         -- Update anything we were handed
10         current_row.value := COALESCE(current_row.value, in_value);
11         current_row.description := COALESCE(current_row.description, in_description);
12         current_row.opac_visible := COALESCE(current_row.opac_visible, in_opac_visible);
13         current_row.search_label := COALESCE(current_row.search_label, in_search_label);
14         current_row.is_simple := COALESCE(current_row.is_simple, in_is_simple);
15         UPDATE config.coded_value_map
16             SET
17                 value = current_row.value,
18                 description = current_row.description,
19                 opac_visible = current_row.opac_visible,
20                 search_label = current_row.search_label,
21                 is_simple = current_row.is_simple
22             WHERE id = current_row.id;
23     ELSE
24         INSERT INTO config.coded_value_map(ctype, code, value, description, opac_visible, search_label, is_simple) VALUES
25             (in_ctype, in_code, in_value, in_description, COALESCE(in_opac_visible, TRUE), in_search_label, COALESCE(in_is_simple, FALSE));
26     END IF;
27 END;
28 $f$ LANGUAGE PLPGSQL;
29
30 SELECT config.update_coded_value_map('vr_format', 'a', 'Beta', add_only := TRUE);
31 SELECT config.update_coded_value_map('vr_format', 'b', 'VHS', add_only := TRUE);
32 SELECT config.update_coded_value_map('vr_format', 'c', 'U-matic', add_only := TRUE);
33 SELECT config.update_coded_value_map('vr_format', 'd', 'EIAJ', add_only := TRUE);
34 SELECT config.update_coded_value_map('vr_format', 'e', 'Type C', add_only := TRUE);
35 SELECT config.update_coded_value_map('vr_format', 'f', 'Quadruplex', add_only := TRUE);
36 SELECT config.update_coded_value_map('vr_format', 'g', 'Laserdisc', add_only := TRUE);
37 SELECT config.update_coded_value_map('vr_format', 'h', 'CED videodisc', add_only := TRUE);
38 SELECT config.update_coded_value_map('vr_format', 'i', 'Betacam', add_only := TRUE);
39 SELECT config.update_coded_value_map('vr_format', 'j', 'Betacam SP', add_only := TRUE);
40 SELECT config.update_coded_value_map('vr_format', 'k', 'Super-VHS', add_only := TRUE);
41 SELECT config.update_coded_value_map('vr_format', 'm', 'M-II', add_only := TRUE);
42 SELECT config.update_coded_value_map('vr_format', 'o', 'D-2', add_only := TRUE);
43 SELECT config.update_coded_value_map('vr_format', 'p', '8 mm.', add_only := TRUE);
44 SELECT config.update_coded_value_map('vr_format', 'q', 'Hi-8 mm.', add_only := TRUE);
45 SELECT config.update_coded_value_map('vr_format', 's', 'Blu-ray disc', add_only := TRUE);
46 SELECT config.update_coded_value_map('vr_format', 'u', 'Unknown', add_only := TRUE);
47 SELECT config.update_coded_value_map('vr_format', 'v', 'DVD', add_only := TRUE);
48 SELECT config.update_coded_value_map('vr_format', 'z', 'Other', add_only := TRUE);
49 SELECT config.update_coded_value_map('vr_format', ' ', 'Unspecified', add_only := TRUE);