[open-ils-commits] r19190 - trunk/Open-ILS/src/sql/Pg (dbwells)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jan 18 13:06:04 EST 2011


Author: dbwells
Date: 2011-01-18 13:06:00 -0500 (Tue, 18 Jan 2011)
New Revision: 19190

Modified:
   trunk/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
Log:
Auto-generation of placeholder barcodes approved for backport


Modified: trunk/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql	2011-01-17 23:34:49 UTC (rev 19189)
+++ trunk/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql	2011-01-18 18:06:00 UTC (rev 19190)
@@ -31,7 +31,7 @@
 
 -- Highest-numbered individual upgrade script incorporated herein:
 
-INSERT INTO config.upgrade_log (version) VALUES ('0474');
+INSERT INTO config.upgrade_log (version) VALUES ('0475');
 
 -- Push the auri sequence in case it's out of date
 -- Add 2 as the sequence value must be 1 or higher, and seed is -1
@@ -19019,6 +19019,20 @@
     SELECT 1 FROM acq.lineitem_marc_attr_definition WHERE code = 'upc'
 );  
 
+-- '@@' auto-placeholder barcode support
+CREATE OR REPLACE FUNCTION asset.autogenerate_placeholder_barcode ( ) RETURNS TRIGGER AS $f$
+BEGIN
+	IF NEW.barcode LIKE '@@%' THEN
+		NEW.barcode := '@@' || NEW.id;
+	END IF;
+	RETURN NEW;
+END;
+$f$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER autogenerate_placeholder_barcode
+	BEFORE INSERT OR UPDATE ON asset.copy
+	FOR EACH ROW EXECUTE PROCEDURE asset.autogenerate_placeholder_barcode();
+
 COMMIT;
 
 -- Some operations go outside of the transaction, because they may



More information about the open-ils-commits mailing list