3 INSERT INTO config.upgrade_log (version) VALUES ('0370');
5 CREATE OR REPLACE FUNCTION biblio.map_authority_linking (bibid BIGINT, marc TEXT) RETURNS BIGINT AS $func$
6 DELETE FROM authority.bib_linking WHERE bib = $1;
7 INSERT INTO authority.bib_linking (bib, authority)
10 FROM ( SELECT DISTINCT $1 AS bib,
11 BTRIM(remove_paren_substring(txt))::BIGINT AS authority
12 FROM explode_array(oils_xpath('//*[@code="0"]/text()',$2)) x(txt)
13 WHERE BTRIM(remove_paren_substring(txt)) ~ $re$^\d+$$re$
14 ) y JOIN authority.record_entry r ON r.id = y.authority;