Finding an ISBN for an item

I've been looking at how to get an ISBN out for an item. I thought it would be simple :)

After a little investigation, it seems WORK_SUBFIELD table, where TAG_ID = 21, is often the place to find the ISBN, in subfields a and q. Q is more likely to contain a 13 digit isbn (but not always).

e.g.
select SUBFIELD, DATA1
From WORK_SUBFIELD
WHERE WORK_ID = 147453
AND TAG_ID = 21

Can any one know what TALIS MARC tag 21 subfield q is? And is it correct to say that subfields q and a are the best place to find an ISBN?

Are there any other places I should be looking in?

Thanks
Chris

code sample to get isbn - for comment/improvement

For reference, here is the code I've created so far (please excuse my poor perl).

It's a perl sub which is passed a workid (and the work's control number). It looks for records in the WORK_SUBFIELD which match this workid, and match tag_no 21. It stores the q and a fields, and will use one of these if they exist (using your preferred length).
If this brings nothing back, it looks at the control_number and does some simple regex to see if it looks like an ISBN, if it does, it uses that, if it doesn't it gives up.

Any ways to improve this, or look else where before deciding we have no ISBN for this item.

All comments welcome!

(sorry, TDN doesn't print out code very well)

$isbn_length="10";

sub getISBN {
$workid = shift;
$control_number = shift;
# Get ISBN
# in TalisMARC/UKMARC MARC tag 21 holds ISBN, it seems in subfields q and a
(@isbn) = &sql($d,"
Select SUBFIELD_CODE, DATA1
From WORK_SUBFIELD
WHERE WORK_ID = $workid
AND TAG_NO = 21
");
my $isbn = "NOISBN";
my $isbnq = "";
my $isbna = "";
my $isbn10 = "";
my $isbn13 = "";
my $isbn_other = "";
$isbn_debug = "";
foreach $isbns(@isbn) {
# for each SUBFIELD record (for this workid, and for tag 21)
# work out which subfield it is and see if it has a good isbn
($subfield, $currentisbn) = split('~', $isbns);
if ($subfield eq "q") {
$isbnq = $currentisbn;
$totalq++;
if (length $isbnq eq 10) {
$isbn10 = $isbnq;
}
elsif (length $isbnq eq 13) {
$isbn13 = $isbnq;
}

}
elsif ($subfield eq "a") {
$isbna = $currentisbn;
$totala++;
if (length $isbna eq 10) {
$isbn10 = $isbna;
}
elsif (length $isbna eq 13) {
$isbn13 = $isbna;
}

}
else {
$isbn_other .= "$subfield $currentisbn,";
$total_other++;
}
}
# now we have all possible ISBNs decide which one to use
# which we use depends if the length we prefer (set above) is
# 10 or 13
if ($isbn_length eq "10") {
# try and use 10 digit isbn
if ($isbn10) { $isbn = $isbn10; }
elsif ($isbn13) {
$isbn = $isbn13;
print DEBUG "WARNING no isbn10 found, using $isbn13 (a $isbna q $isbnq con $control_number) \n\n";
}
}
elsif ($isbn_length eq "13") {
if ($isbn10) { $isbn = $isbn10; }
elsif ($isbn13) { $isbn = $isbn13; }
}
# if we don't have a isbn 10 or 13 try control number
if ($isbn eq "NOISBN") {
# control number looks like a 10 digit isbn
if ($control_number =~ /^\d{9}[\d|X]$/) { $isbn = $control_number; }
# control number looks like a 13 digit isbn
elsif ($control_number =~ /^\d{13}$/) { $isbn = "$control_number"; }
}

# return isbn
print DEBUG "ISBN q $isbnq a $isbna other($isbn_other) control $control_number final $isbn\n";
return $isbn;
}

Chris Keene - University of Sussex.

Finding an ISBN

The WORK_SUBFIELD.TAG_NO = 21 will usually hold an ISBN, but it might hold other sorts of numbers as well because of old workrounds. In older records, though, there might not be a tag 21 if the ISBN was held in 001.

It might be easier to look in M21_STANDARD_NUMBER where TAG = 20. It might still produce some false hits (i.e. cases where old records contained something other than an ISBN in tag 21, that got converted to M21 tag 20), but it’s probably going to produce better results.

Thanks

Brian Crampton
Developer, Talis

M21_STANDARD_NUMBER looks

M21_STANDARD_NUMBER looks useful. Didn't know about it. Thanks

Chris Keene - University of Sussex.