Teach asset.merge_record_assets about STRING_AGG()
authorDan Scott <dscott@laurentian.ca>
Thu, 13 Oct 2011 22:56:26 +0000 (18:56 -0400)
committerDan Scott <dscott@laurentian.ca>
Fri, 7 Feb 2014 22:00:14 +0000 (17:00 -0500)
Now that asset.merge_record_assets() is working, cut over to
STRING_AGG() so it can iterate over those unnecessary nodes faster :)

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/sql/Pg/999.functions.global.sql

index 070c583..ac20ce7 100644 (file)
@@ -1003,17 +1003,15 @@ BEGIN
                        ' tag="856"' ||
                        ' ind1="' || FIRST(ind1) || '"'  ||
                        ' ind2="' || FIRST(ind2) || '">' ||
-                        array_to_string(
-                            ARRAY_AGG(
-                                '<subfield code="' || subfield || '">' ||
+                        STRING_AGG(
+                            '<subfield code="' || subfield || '">' ||
+                            regexp_replace(
                                 regexp_replace(
-                                    regexp_replace(
-                                        regexp_replace(data,'&','&amp;','g'),
-                                        '>', '&gt;', 'g'
-                                    ),
-                                    '<', '&lt;', 'g'
-                                ) || '</subfield>'
-                            ), ''
+                                    regexp_replace(data,'&','&amp;','g'),
+                                    '>', '&gt;', 'g'
+                                ),
+                                '<', '&lt;', 'g'
+                            ) || '</subfield>', ''
                         ) || '</datafield>' INTO uri_datafield
               FROM  oils_xpath_table(
                         'id',