added new function to pad barcodes
authorGalen Charlton <gmc@esilibrary.com>
Mon, 24 Aug 2009 16:20:34 +0000 (16:20 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 24 Aug 2009 16:20:34 +0000 (16:20 +0000)
commitece48e9a23f8f60279d21642d7c37586e5dcecef
treef5be7c0a3ad9e07c12614671ef69a1e13dd0c5d5
parent4a4edef442207806b9d0ba5ea5a8cc3b350a89ce
added new function to pad barcodes

-- expand_barcode
--   $barcode      source barcode
--   $prefix       prefix to add to barcode, NULL = add no prefix
--   $maxlen       maximum length of barcode; default to 14 if left NULL
--   $pad          padding string to apply to left of source barcode before adding
--                 prefix and suffix; set to NULL or '' if no padding is desired
--   $suffix       suffix to add to barcode, NULL = add no suffix
--
-- Returns a new string consisting of prefix concatenated with padded barcode and suffix.
-- If new barcode would be longer than $maxlen, the original barcode is returned instead.

Example usage:

UPDATE foo
SET barcode = migration_tools.expand_barcode(barcode, '21234', 14, '0', '');
sql/base/base.sql