misc cleanup
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 Sep 2005 22:21:57 +0000 (22:21 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 Sep 2005 22:21:57 +0000 (22:21 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1824 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/020.schema.functions.sql
Open-ILS/src/sql/Pg/040.schema.asset.sql

index 8d1fe38..1b3682a 100644 (file)
@@ -1,3 +1,15 @@
+CREATE OR REPLACE FUNCTION asset.call_number_dewey( TEXT ) RETURNS TEXT AS $$
+       my $txt = shift;
+       $txt =~ s/^\s+//o;
+       $txt =~ s/[\[\]\{\}\(\)`'"#<>\*\?\-\+\$\\]+//o;
+       $txt =~ s/\s+$//o;
+       if (/(\d{3}(?:\.\d+)?)/o) {
+               return $1;
+       } else {
+               return (split /\s+/, $txt)[0];
+       }
+$$ LANGUAGE 'plperl' STRICT IMMUTABLE;
+
 CREATE OR REPLACE FUNCTION public.text_concat ( TEXT, TEXT ) RETURNS TEXT AS $$
 SELECT
        CASE    WHEN $1 IS NULL
@@ -98,4 +110,9 @@ CREATE OR REPLACE FUNCTION actor.org_unit_proximity ( INT, INT ) RETURNS INT AS
        ) z;
 $$ LANGUAGE SQL STABLE;
 
-
+CREATE AGGREGATE array_accum (
+       sfunc = array_append,
+       basetype = anyelement,
+       stype = anyarray,
+       initcond = '{}'
+);
index 84b4005..1e00dd4 100644 (file)
@@ -121,6 +121,7 @@ CREATE TABLE asset.call_number (
 CREATE INDEX asset_call_number_record_idx ON asset.call_number (record);
 CREATE INDEX asset_call_number_creator_idx ON asset.call_number (creator);
 CREATE INDEX asset_call_number_editor_idx ON asset.call_number (editor);
+CREATE INDEX asset_call_number_dewey_idx ON asset.call_number (asset.call_number_dewey(label));
 
 CREATE TABLE asset.call_number_note (
        id              BIGSERIAL                       PRIMARY KEY,