From 1e915adfefcc1b6a52753130718c046a600b5f13 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 29 Mar 2011 16:06:26 +0000 Subject: [PATCH] Missed function in upgrade script git-svn-id: svn://svn.open-ils.org/ILS/trunk@19887 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/sql/Pg/upgrade/0504.schema.parts_and_cnaffix.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Open-ILS/src/sql/Pg/upgrade/0504.schema.parts_and_cnaffix.sql b/Open-ILS/src/sql/Pg/upgrade/0504.schema.parts_and_cnaffix.sql index 5245e37f6..020a78a81 100644 --- a/Open-ILS/src/sql/Pg/upgrade/0504.schema.parts_and_cnaffix.sql +++ b/Open-ILS/src/sql/Pg/upgrade/0504.schema.parts_and_cnaffix.sql @@ -2,6 +2,21 @@ BEGIN; INSERT INTO config.upgrade_log (version) VALUES ('0504'); -- miker +CREATE OR REPLACE FUNCTION lpad_number_substrings( TEXT, TEXT, INT ) RETURNS TEXT AS $$ + my $string = shift; + my $pad = shift; + my $len = shift; + my $find = $len - 1; + + while ($string =~ /(?:^|\D)(\d{1,$find})(?:$|\D)/) { + my $padded = $1; + $padded = $pad x ($len - length($padded)) . $padded; + $string =~ s/$1/$padded/sg; + } + + return $string; +$$ LANGUAGE PLPERLU; + CREATE TABLE biblio.monograph_part ( id SERIAL PRIMARY KEY, record BIGINT NOT NULL REFERENCES biblio.record_entry (id), -- 2.11.0