How to add fixed-length characters before the accession number in all books of Koha

Oct - 03
2022

How to add fixed-length characters before the accession number in all books of Koha

Situation

In an academic library that used a proprietary software called Bookmagic software that has a feature in the library settings that when a book is stored with an accession number, it automatically adds  zero to create a fixed length (6 digit) number in front of the accession number. For example, if we catalogue a book with accession number 120, it will be stored in its database as 000120, if it were 20000, it will be 020000

The library itself migrated the data to Koha ignoring the zero prefix and started circulation. 3 months later, when the library was using the barcode scanner for circulation purposes, it noticed that by scanning the barcode label of the book, which was created by the old software, which turned out to be unavailable in the system due to the barcode also have prefix number (zero ), where the number was printed in it does not have a zero prefix.

The Solution

The library has 2 solutions, adding a zero to create a fixed length numeric number (here it’s a 6 digit number)  in all books accession numbers, or regenerating the barcode label. We fixed it with the first solution by follow method.

“Before the action please make a backup of the MySQL DB”

Use the MySQL query

sudo mysql -uroot –p
use koha_library; ("library" Instance Name)
UPDATE items SET barcode = lpad(barcode , 6 , '0'); exit;

This will update all accession numbers to six-digit length numbers with ‘0’ as leading

Case 2

If you want to reverse the above, use the below command to remove all leading zeros in the accession number

UPDATE items SET barcode = trim(LEADING '0' FROM barcode);

Case 3

If we want to delete a prefix character from all books barcode have, for example, ‘GEN’ from all books the command will be

UPDATE items SET barcode = trim(LEADING 'GEN' FROM barcode);

Case 4

If we want to delete a suffix character from all books barcode have, for example, GEN from all books the command will be

UPDATE items SET barcode = trim(TRAILING 'GEN' FROM barcode);

2 Replies to “How to add fixed-length characters before the accession number in all books of Koha”

  1. How can we do the same steps for removing lead zeros in accession number of koha is installed in Windows platform?

    1. Koha Community not released Windows version yet. If you are using Koha in windows installed version you have to contact the developed authority not only for this any kind of deep fixing.

Leave a Reply

Your email address will not be published. Required fields are marked *

Open chat
Powered by
Close Bitnami banner