[Koha] same barcode number

Jared Jennings jjenning at gmail.com
Tue Dec 21 22:02:53 NZDT 2004


On Thu, 16 Dec 2004 17:27:20 -0800 (PST), Yohannes Mulugeta
<yohannesmulu at yahoo.com> wrote:
> we are trying to add items to the
> biblio but it accepts
> the same barcode number for different items. Can any
> body help us?

you can run the following sql statement to enforce uniqueness of barcodes.

alter table items change barcode barcode varchar(20) not null unique;

you must of course do this from the mysql client - example

$ mysql -u root -p Koha
Password: .......
mysql> alter table items change barcode barcode varchar(20) not null unique;
ERROR 1062: Duplicate entry '' for key 2
mysql>

if you have any duplicates or empty barcodes when you try to run the
sql command, it will stop with an error like this. you must fix all
the duplicates before it will work.

unfortunately NULL == NULL, so if you want to require that all
barcodes be unique, you must also require that they be supplied (not
null). that's what the error in the example above means: the first
record has a null barcode, and so does the second. that's not unique!
so "fixing all the duplicates" as i said above also means making sure
every item has a barcode.

the requirement to enter barcodes (and to have unique ones) was
removed in Sept. 2003, for those who don't wish to use them in their
libraries i presume (anyone else, jump in here...). you can see the
changes to the code of the updater script at
http://cvs.sourceforge.net/viewcvs.py/koha/koha/updater/updatedatabase?r1=1.58&r2=1.59



More information about the Koha mailing list