From 0a445868a22180f90395407b5f1f1dfa6002a664 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Tue, 13 Jan 2015 09:09:08 -0500 Subject: [PATCH] Enrich the MARC records and track the enrichment Still need to do error-handling so we can report problems encountered with individual records and continue on in a cron job, but this gets us a good chunk of the way there. Signed-off-by: Dan Scott --- Open-ILS/src/sql/Pg/update_marc_records_in_database.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Open-ILS/src/sql/Pg/update_marc_records_in_database.sql b/Open-ILS/src/sql/Pg/update_marc_records_in_database.sql index 4d3395dcde..448b2341e2 100644 --- a/Open-ILS/src/sql/Pg/update_marc_records_in_database.sql +++ b/Open-ILS/src/sql/Pg/update_marc_records_in_database.sql @@ -189,3 +189,16 @@ CREATE OR REPLACE FUNCTION conifer.marc_version() RETURNS TEXT AS $func$ use MARC::Record; return $MARC::Record::VERSION; $func$ LANGUAGE PLPERLU; + +CREATE OR REPLACE FUNCTION conifer.enrich_next() RETURNS BIGINT AS $func$ +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; + 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; + RETURN next_id; +END; +$func$ LANGUAGE PLPGSQL; -- 2.11.0