Serials: point MFHD records at the master bib record when merging bibs
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 25 May 2009 03:19:57 +0000 (03:19 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 25 May 2009 03:19:57 +0000 (03:19 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13222 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/090.schema.action.sql

index 2b13c93..1140dd4 100644 (file)
@@ -356,6 +356,7 @@ DECLARE
        target_cn     asset.call_number%ROWTYPE;
        metarec       metabib.metarecord%ROWTYPE;
        hold          action.hold_request%ROWTYPE;
+       ser_rec       serial.record_entry%ROWTYPE;
     uri_count     INT := 0;
     counter       INT := 0;
     uri_datafield TEXT;
@@ -476,6 +477,16 @@ BEGIN
                moved_objects := moved_objects + 1;
        END LOOP;
 
+       -- Find serial records targeting the source record ...
+       FOR ser_rec IN SELECT * FROM serial.record_entry WHERE record = source_record LOOP
+               -- ... and move them to the target record
+               UPDATE  serial.record_entry
+                 SET   record = target_record
+                 WHERE id = ser_rec.id;
+
+               moved_objects := moved_objects + 1;
+       END LOOP;
+
     -- Finally, "delete" the source record
     DELETE FROM biblio.record_entry WHERE id = source_record;