Adjust hold-to-record view to cover I, F and R hold types
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 27 Sep 2010 16:15:14 +0000 (16:15 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 27 Sep 2010 16:15:14 +0000 (16:15 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18027 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/reporter-schema.sql
Open-ILS/src/sql/Pg/upgrade/0419.schema.hold_record_view.sql [new file with mode: 0644]

index d6e3e80..9da0d72 100644 (file)
@@ -70,7 +70,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0418'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0419'); -- miker
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 4492d6c..a4fa038 100644 (file)
@@ -305,9 +305,11 @@ SELECT     id,
        CASE
                WHEN hold_type = 'T'
                        THEN target
+               WHEN hold_type = 'I'
+                       THEN (SELECT ssub.record_entry FROM serial.subscription ssub JOIN serial.issuance si ON (si.subscription = ssub.id) WHERE si.id = ahr.target)
                WHEN hold_type = 'V'
                        THEN (SELECT cn.record FROM asset.call_number cn WHERE cn.id = ahr.target)
-               WHEN hold_type = 'C'
+               WHEN hold_type IN ('C','R','F')
                        THEN (SELECT cn.record FROM asset.call_number cn JOIN asset.copy cp ON (cn.id = cp.call_number) WHERE cp.id = ahr.target)
                WHEN hold_type = 'M'
                        THEN (SELECT mr.master_record FROM metabib.metarecord mr WHERE mr.id = ahr.target)
diff --git a/Open-ILS/src/sql/Pg/upgrade/0419.schema.hold_record_view.sql b/Open-ILS/src/sql/Pg/upgrade/0419.schema.hold_record_view.sql
new file mode 100644 (file)
index 0000000..350dc78
--- /dev/null
@@ -0,0 +1,23 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0419'); -- miker
+
+CREATE OR REPLACE VIEW reporter.hold_request_record AS
+SELECT  id,
+    target,
+    hold_type,
+    CASE
+        WHEN hold_type = 'T'
+            THEN target
+        WHEN hold_type = 'I'
+            THEN (SELECT ssub.record_entry FROM serial.subscription ssub JOIN serial.issuance si ON (si.subscription = ssub.id) WHERE si.id = ahr.target)
+        WHEN hold_type = 'V'
+            THEN (SELECT cn.record FROM asset.call_number cn WHERE cn.id = ahr.target)
+        WHEN hold_type IN ('C','R','F')
+            THEN (SELECT cn.record FROM asset.call_number cn JOIN asset.copy cp ON (cn.id = cp.call_number) WHERE cp.id = ahr.target)
+        WHEN hold_type = 'M'
+            THEN (SELECT mr.master_record FROM metabib.metarecord mr WHERE mr.id = ahr.target)
+    END AS bib_record
+  FROM  action.hold_request ahr;
+
+COMMIT;