Continue enriching in the face of errors
authorDan Scott <dscott@laurentian.ca>
Fri, 16 Jan 2015 20:42:08 +0000 (15:42 -0500)
committerDan Scott <dscott@laurentian.ca>
Fri, 16 Jan 2015 20:42:08 +0000 (15:42 -0500)
Adjust the conifer.enriched_bre table to track the success
or failure of updates; this will then enable us to easily
generate a list of the problematic bibs that need to be
revisited.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/update_marc_records_in_database.sql

index 448b234..ede6ca1 100644 (file)
@@ -195,10 +195,13 @@ DECLARE
     last_id BIGINT;
     next_id BIGINT;
 BEGIN
-    SELECT id INTO last_id FROM conifer.conifer.enriched_bre LIMIT 1;
-    SELECT id INTO next_id FROM asset.opac_visible_copies WHERE id > last_id ORDER BY id LIMIT 1;
+    SELECT id INTO last_id FROM conifer.conifer.enriched_bre ORDER BY id DESC LIMIT 1;
+    SELECT record INTO next_id FROM asset.call_number WHERE record > last_id AND deleted IS FALSE AND owning_lib IN (103, 105, 131, 150) ORDER BY record LIMIT 1;
     UPDATE biblio.record_entry SET marc = conifer.enrich_uris(next_id), edit_date = NOW() WHERE id = next_id;
-    UPDATE conifer.enriched_bre SET id = next_id;
+    INSERT INTO conifer.enriched_bre (id, success, result) VALUES (next_id, TRUE, NULL);
+    RETURN next_id;
+EXCEPTION
+    WHEN OTHERS THEN INSERT INTO conifer.enriched_bre (id, success, result) VALUES (next_id, FALSE, SQLERRM);
     RETURN next_id;
 END;
 $func$ LANGUAGE PLPGSQL;