[OPEN-ILS-DEV] Placeholder Auto-barcodes, Take Two

Dan Wells dbw2 at calvin.edu
Tue Dec 14 11:38:00 EST 2010


Hello all,

Way back in March I sent a message to the list about adding an auto-barcode database trigger which didn't get a whole lot of traction, so this is a second, simpler attempt at the same idea.

To be clear, I am not talking about functionality where we auto-generate *real* barcodes based on barcode sequence logic, as that already exists in the places it is needed.  I am instead talking about a simple way to insert a 'filler' barcode when cataloging an item which (for whatever reason) doesn't have (or need) a real barcode.

In my first message I included a more complex trigger function than was really necessary.  I now think the following will suffice:

CREATE OR REPLACE FUNCTION asset.autogenerate_placeholder_barcode ( ) RETURNS TRIGGER AS $$
BEGIN
	IF UPPER(NEW.barcode) = 'AUTO' THEN
		NEW.barcode := '@@' || NEW.id;
	END IF;
	RETURN NEW;
END;
$$ LANGUAGE PLPGSQL;

CREATE TRIGGER autogenerate_barcode
	BEFORE INSERT OR UPDATE ON asset.copy
	FOR EACH ROW EXECUTE PROCEDURE asset.autogenerate_placeholder_barcode();

As suggested by Jason, this simply uses the copy id to ensure uniqueness.  Overall consequences of this change would be that all forms of the word 'auto' are now effectively reserved from being valid barcode data, as well as any barcode starting with '@@'.  It would of course be fine to change either of these markers if someone suggests a reason to do so.

Thoughts?

Thanks,
Dan



-- 
*********************************************************************************
Daniel Wells, Library Programmer Analyst dbw2 at calvin.edu
Hekman Library at Calvin College
616.526.7133




More information about the Open-ils-dev mailing list