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 <dscott@laurentian.ca>
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;