return $barcode if (length($prefix) + length($new_barcode) + length($suffix)) > $maxlen;
return "$prefix$new_barcode$suffix";
-$$ LANGUAGE PLPERL STABLE;
+$$ LANGUAGE PLPERLU STABLE;
CREATE OR REPLACE FUNCTION migration_tools.attempt_cast (TEXT,TEXT,TEXT) RETURNS RECORD AS $$
DECLARE
my $remainder = $total % 10;
my $checkdigit = ($remainder == 0) ? $remainder : 10 - $remainder;
return $barcode . $checkdigit;
-$$ LANGUAGE PLPERL STRICT STABLE;
+$$ LANGUAGE PLPERLU STRICT STABLE;
CREATE OR REPLACE FUNCTION migration_tools.attempt_phone (TEXT,TEXT) RETURNS TEXT AS $$
DECLARE
WHEN TRUE THEN (rmf.amount / 100.0) * ac.price
ELSE rmf.amount
END,
- renewal_remaining = rcd.max_renewals
+ renewal_remaining = rcd.max_renewals,
+ grace_period = rrf.grace_period
FROM
config.rule_circ_duration rcd,
config.rule_recurring_fine rrf,
$func$ LANGUAGE PLPERLU;
COMMENT ON FUNCTION migration_tools.marc_parses(TEXT) IS 'Return boolean indicating if MARCXML string is parseable by MARC::File::XML';
+CREATE OR REPLACE FUNCTION migration_tools.simple_export_library_config(dir TEXT, orgs INT[]) RETURNS VOID AS $FUNC$
+BEGIN
+ EXECUTE $$COPY (SELECT * FROM actor.hours_of_operation WHERE id IN ($$ ||
+ ARRAY_TO_STRING(orgs, ',') || $$)$$ ||
+ $$) TO '$$ || dir || $$/actor_hours_of_operation'$$;
+ EXECUTE $$COPY (SELECT org_unit, close_start, close_end, reason FROM actor.org_unit_closed WHERE org_unit IN ($$ ||
+ ARRAY_TO_STRING(orgs, ',') || $$)$$ ||
+ $$) TO '$$ || dir || $$/actor_org_unit_closed'$$;
+ EXECUTE $$COPY (SELECT org_unit, name, value FROM actor.org_unit_setting WHERE org_unit IN ($$ ||
+ ARRAY_TO_STRING(orgs, ',') || $$)$$ ||
+ $$) TO '$$ || dir || $$/actor_org_unit_setting'$$;
+ EXECUTE $$COPY (SELECT name, owning_lib, holdable, hold_verify, opac_visible, circulate FROM asset.copy_location WHERE owning_lib IN ($$ ||
+ ARRAY_TO_STRING(orgs, ',') || $$)$$ ||
+ $$) TO '$$ || dir || $$/asset_copy_location'$$;
+END;
+$FUNC$ LANGUAGE PLPGSQL;
+