Field 001 auto-increment problem in 3.8.5
Our cataloguing frameworks (default, books) for tag 001 have under Constraints / Other Options / Plugin a script [callnumber_rev3.pl, one line changed from the Koha "standard" callnumber.pl] which includes this snippet: # If the textbox is empty, we return a simple incremented controlnumber [was callnumber] if ( $code eq "" ) { - my $sth = $dbh->prepare("SELECT MAX(CAST(itemcallnumber AS SIGNED)) FROM items"); + my $sth = $dbh->prepare("SELECT MAX(CAST(EXTRACTVALUE(marcxml,'//controlfield[\@tag=\"001\"]') AS SIGNED)) from biblioitems"); $sth->execute; if ( my $max = $sth->fetchrow ) { $template->param( return => $max+1, ); } The need for this change is that marcxml,'//controlfield[\@tag=\"001\"]' correctly returns 39029463224 (mysql output below my sig.) LoC, BL, LAC, etc all *occasionally* have alpha suffixes - hence the "EXTRACTVALUE". BUT -- when cataloguing, using the plugin for a blank 001 input, it gets stuck on 39029463221 and therefore produces duplicates. I've even tried return => $max+5 but no change ... it still produces $max-3. Rebooting, no change ;-{ A numeric sort of the marcxml 001 tags appears normal: .../ 39029463218 39029463219 39029463220 39029463221 39029463222 39029463223 39029463224 I've spent a couple of hours trying to chase this one down and would really appreciate help. Thanks and br -- Paul mysql> SELECT MAX(CAST(EXTRACTVALUE(marcxml,'//controlfield[@tag="001"]')AS SIGNED)) FROM biblioitems; +------------------------------------------------------------------------+ | MAX(CAST(EXTRACTVALUE(marcxml,'//controlfield[@tag="001"]')AS SIGNED)) | +------------------------------------------------------------------------+ | 39029463224 | +------------------------------------------------------------------------+ 1 row in set, 307 warnings (0.14 sec) ### These warnings are for $ rather than numeric entries
participants (1)
-
Paul