[open-ils-commits] r15354 - trunk/Open-ILS/src/sql/Pg/upgrade (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jan 21 11:43:29 EST 2010


Author: miker
Date: 2010-01-21 11:43:26 -0500 (Thu, 21 Jan 2010)
New Revision: 15354

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0139.schema.vandelay-item-import-fix.sql
Log:
upgrade script to accompany r15353

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0139.schema.vandelay-item-import-fix.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0139.schema.vandelay-item-import-fix.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0139.schema.vandelay-item-import-fix.sql	2010-01-21 16:43:26 UTC (rev 15354)
@@ -0,0 +1,66 @@
+
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0139'); -- Dan Wells via miker
+
+CREATE OR REPLACE FUNCTION vandelay.ingest_bib_items ( ) RETURNS TRIGGER AS $func$
+DECLARE
+    attr_def    BIGINT;
+    item_data   vandelay.import_item%ROWTYPE;
+BEGIN
+
+    SELECT item_attr_def INTO attr_def FROM vandelay.bib_queue WHERE id = NEW.queue;
+
+    FOR item_data IN SELECT * FROM vandelay.ingest_items( NEW.id::BIGINT, attr_def ) LOOP
+        INSERT INTO vandelay.import_item (
+            record,
+            definition,
+            owning_lib,
+            circ_lib,
+            call_number,
+            copy_number,
+            status,
+            location,
+            circulate,
+            deposit,
+            deposit_amount,
+            ref,
+            holdable,
+            price,
+            barcode,
+            circ_modifier,
+            circ_as_type,
+            alert_message,
+            pub_note,
+            priv_note,
+            opac_visible
+        ) VALUES (
+            NEW.id,
+            item_data.definition,
+            item_data.owning_lib,
+            item_data.circ_lib,
+            item_data.call_number,
+            item_data.copy_number,
+            item_data.status,
+            item_data.location,
+            item_data.circulate,
+            item_data.deposit,
+            item_data.deposit_amount,
+            item_data.ref,
+            item_data.holdable,
+            item_data.price,
+            item_data.barcode,
+            item_data.circ_modifier,
+            item_data.circ_as_type,
+            item_data.alert_message,
+            item_data.pub_note,
+            item_data.priv_note,
+            item_data.opac_visible
+        );
+    END LOOP;
+
+    RETURN NULL;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+COMMIT;



More information about the open-ils-commits mailing list