Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use warnings;
- use strict;
- use Text::CSV qw/ csv /;
- my $file = 'renewal_policies.csv';
- my $policies = csv (in => "$file", headers => "skip", empty_is_undef => 1, undef_str => "NULL");
- # Perm Group,Org Unit,Copy Circ Lib,Renewal?,Circulation Modifier,Reference?,Circulate?,Duration Rule,Recurring Fine Rule,Max Fine Rule,Early Renewal Extends Due Date,Early Renewal Minimum Duration Interval
- foreach my $policy (@$policies) {
- print "insert into config.circ_matrix_matchpoint (
- grp,
- org_unit,
- copy_circ_lib,
- is_renewal,
- circ_modifier,
- ref_flag,
- circulate,
- duration_rule,
- recurring_fine_rule,
- max_fine_rule,
- renew_extends_due_date,
- renew_extend_min_interval
- ) values (
- (select id from permission.grp_tree where name = '@$policy[0]'),
- (select id from actor.org_unit where shortname = '@$policy[1]'),\n\t\t"
- . (@$policy[2] ? "(select id from actor.org_unit where shortname = '@$policy[2]'),\n\t\t" : "NULL,\n\t\t")
- . (@$policy[3] ? "@$policy[3],\n\t\t" : "NULL,\n\t\t")
- . (@$policy[4] ? "(select code from config.circ_modifier where name = '@$policy[4]'),\n\t\t" : "NULL,\n\t\t")
- . (@$policy[5] ? "@$policy[5],\n\t\t" : "NULL,\n\t\t")
- . (@$policy[6] ? "@$policy[6],\n\t\t" : "NULL,\n\t\t")
- . (@$policy[7] ? "(select id from config.rule_circ_duration where name = '@$policy[7]'),\n\t\t" : "NULL,\n\t\t")
- . (@$policy[8] ? "(select id from config.rule_recurring_fine where name = '@$policy[8]'),\n\t\t" : "NULL,\n\t\t")
- . (@$policy[9] ? "(select id from config.rule_max_fine where name = '@$policy[9]'),\n\t\t" : "NULL,\n\t\t")
- . "@$policy[10],\n\t\t"
- . "'@$policy[11]'"
- . ");\n\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement