3 SELECT evergreen.upgrade_deps_block_check('1022', :eg_version);
5 CREATE OR REPLACE FUNCTION vandelay.merge_record_xml_using_profile ( incoming_marc TEXT, existing_marc TEXT, merge_profile_id BIGINT ) RETURNS TEXT AS $$
7 merge_profile vandelay.merge_profile%ROWTYPE;
8 dyn_profile vandelay.compile_profile%ROWTYPE;
15 IF existing_marc IS NULL OR incoming_marc IS NULL THEN
16 -- RAISE NOTICE 'no marc for source or target records';
20 IF merge_profile_id IS NOT NULL THEN
21 SELECT * INTO merge_profile FROM vandelay.merge_profile WHERE id = merge_profile_id;
23 dyn_profile.add_rule := COALESCE(merge_profile.add_spec,'');
24 dyn_profile.strip_rule := COALESCE(merge_profile.strip_spec,'');
25 dyn_profile.replace_rule := COALESCE(merge_profile.replace_spec,'');
26 dyn_profile.preserve_rule := COALESCE(merge_profile.preserve_spec,'');
28 -- RAISE NOTICE 'merge profile not found';
32 -- RAISE NOTICE 'no merge profile specified';
36 IF dyn_profile.replace_rule <> '' AND dyn_profile.preserve_rule <> '' THEN
37 -- RAISE NOTICE 'both replace [%] and preserve [%] specified', dyn_profile.replace_rule, dyn_profile.preserve_rule;
41 IF dyn_profile.replace_rule = '' AND dyn_profile.preserve_rule = '' AND dyn_profile.add_rule = '' AND dyn_profile.strip_rule = '' THEN
42 -- Since we have nothing to do, just return a target record as is
44 ELSIF dyn_profile.preserve_rule <> '' THEN
45 source_marc = existing_marc;
46 target_marc = incoming_marc;
47 replace_rule = dyn_profile.preserve_rule;
49 source_marc = incoming_marc;
50 target_marc = existing_marc;
51 replace_rule = dyn_profile.replace_rule;
54 RETURN vandelay.merge_record_xml( target_marc, source_marc, dyn_profile.add_rule, replace_rule, dyn_profile.strip_rule );