On Tue, Jan 17, 2012 at 04:42:38PM +0100, Zeno Tajoli wrote: > Hi Dobrica, > > Il 17/01/2012 16:32, Dobrica Pavlinusic ha scritto: > > I need help from people who use stocknumbers in their Koha's installs. > [..] > > For a start, why is index defined on items.stocknumber non-unique? > > I would assume that it has to be unique like barcode is (at least that's > > our legal requirement). > > I think it is impossiblr to ask for a unique value at MySQL level.
It's not totally impossible. You just have to use trasactions and additional table to hold last value[1] or in case on invetory all values and a little bit of additional meta data[2] 1: http://git.rot13.org/?p=koha.git;a=commitdiff;h=01580945128cb727a404249c7898e6d101f10ceb This is first implementation of sequences which uses mysql routine to provide increment but also requires modification of CGI code to call it on save action. 2: http://git.rot13.org/?p=koha.git;a=blob;f=cataloguing/value_builder/ffzg-stocknumber.pl;h=0239f37984bf5f5b43016a5db288af84466b9f86 This is a value_builder only implementation which moves mysql routine into AJAX callback with transaction. This nicely side-steps problem with uniqueness (since every AJAX request will produce new value and populate one row in invetory table) but it's triggered on plugin invocation (dots in Koha interface) as opposed to save time. I would really love if value builder plugins would have some kind of "on_save" hook, in which I can get item record and save some additional data into inventory table. This would also help with cases in which plugin is activated (and number reserved) but item is never saved. For now I will have to do this via cron script (which I plan to run daily, so you can tweak item data during same day when new stock number is issued and invetory will reflect state at end of this day). -- Dobrica Pavlinusic 2share!2flame [email protected] Unix addict. Internet consultant. http://www.rot13.org/~dpavlin _______________________________________________ Koha-devel mailing list [email protected] http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
