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

Dan Wells dbw2 at calvin.edu
Tue Dec 14 17:12:54 EST 2010


Hello again,

This topic was discussed at the IRC developer's meeting today.  Here is an updated version of the function for review:

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

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

This change accomplishes three things:

1. We only need to reserve '@@' barcodes, not all the forms of the word 'AUTO'
2. Any attempt to manually insert a barcode in the '@@' namespace will be overridden, thus avoiding any possible collisions.
3. Future interfaces, load profiles, etc. can choose to use any convention they like for the "triggering" barcode (e.g. '@@PLACEHOLDER, '@@AUTO', '@@DUMMY', simply '@@', etc.)

Feedback always welcome.

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