[Koha-devel] Imported MARC notice and Authorities: : inconsistent database
Frère Sébastien Marie
semarie-koha at latrappe.fr
Tue Feb 22 17:38:31 CET 2011
Hi,
I ask review for my (start of) solution, against inconsitent between authority (auth_header.auth_id) and koha_internal_code (like 700$9).
The restoration of the consistent should be in 2 stages:
- stop inconsistent growing
- relinks authorities
This is for the first stage: stop inconsistent growing... (as we continue to catalog using some external marc files)
Currently, 'cataloguing/addbiblio.pl' not check authorities if field like 700$9 exists (see BiblioAddAuthorities function).
If a subfield '3' or '9' exists in field 500, 600,..., 700... there is not search for authority and the function assume the koha_internal_number is right (I think this behaviour is wrong).
So, I want to strip this subfield: if no subfield, BiblioAddAuthorities will search for authority and create it if not found.
Here a piece of code (the most part is taken from 'BiblioAddAuthorities') :
sub BiblioCleanKohaInternalCode {
my ( $record, $frameworkcode ) = @_;
my $dbh=C4::Context->dbh;
my $query=$dbh->prepare(qq|
SELECT authtypecode,tagfield
FROM marc_subfield_structure
WHERE frameworkcode=?
AND (authtypecode IS NOT NULL AND authtypecode<>\"\")|);
$query->execute($frameworkcode ? $frameworkcode : '');
while (my $data=$query->fetchrow_hashref){
foreach my $field ($record->field($data->{tagfield})){
# clean code 3 and 9 (if exists)
$field->delete_subfield(code => ['3', '9']);
}
}
}
and I call it just after 'MARCfindbreeding', in order to sanitize the record just getted.
It seems to function well: the page show record without xxx$9, and at the creation of the notice, authorities are search, found or created, and linked.
But what do you think: is it safe or not, to strip '3' and '9' code in these fields ?
Thanks.
--
Frère Sébastien Marie
Abbaye Notre Dame de La Trappe
61380 Soligny-la-Trappe
Tél: 02.33.84.17.00
Fax: 02.33.34.98.57
Web: http://www.latrappe.fr/
More information about the Koha-devel
mailing list