Upgrade script to populate authority.simple_heading
authorMike Rylander <mrylander@gmail.com>
Wed, 26 Oct 2011 17:05:17 +0000 (13:05 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Wed, 26 Oct 2011 22:32:47 +0000 (18:32 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/src/sql/Pg/upgrade/XXXX.data.populate_authority_simple_heading.sql [new file with mode: 0644]

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.populate_authority_simple_heading.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.populate_authority_simple_heading.sql
new file mode 100644 (file)
index 0000000..c42cb85
--- /dev/null
@@ -0,0 +1,23 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+DO $$
+DECLARE x TEXT;
+BEGIN
+
+    FOR x IN
+        SELECT  marc
+          FROM  authority.record_entry
+          WHERE id > 0
+                AND NOT deleted
+                AND id NOT IN (SELECT DISTINCT record FROM authority.simple_heading)
+    LOOP
+        INSERT INTO authority.simple_heading (record,atag,value,sort_value)
+            SELECT record, atag, value, sort_value FROM authority.simple_heading_set(x);
+    END LOOP;
+END;
+$$;
+
+COMMIT;
+