my $bootstrap = '/openils/conf/opensrf_core.xml';
my @records;
my $verbose;
+my $input_file ='';
my $db_host = $ENV{PGHOST} || 'localhost';
my $db_port = $ENV{PGPORT} || '5432';
my $db_user = $ENV{PGDATABASE} || 'evergreen';
'record=i' => \@records,
'all', 'help',
'start_id=i' => \$start_id,
- 'end_id=i' => \$end_id,
- 'verbose' => \$verbose,
+ 'end_id=i' => \$end_id,
+ 'file=s' => \$input_file,
+ 'verbose' => \$verbose,
"db-host=s" => \$db_host,
"db-user=s" => \$db_user,
"db-pass=s" => \$db_pass,
} elsif ($start_id and $end_id) {
$query = sprintf($query, "WHERE sh2.record BETWEEN ? AND ?");
@bind_params = ($start_id, $end_id);
+
+} elsif ($input_file) {
+ # Load authority record IDs from a file.
+ announce("Reading authority record IDs from $input_file");
+
+ open FILE, "<", $input_file or die "Can't open file $input_file\n";
+ while(<FILE>) {
+ chomp;
+ push(@records, $_) if $_;
+ }
+ close FILE;
+
+ announce("Read ".scalar(@records)." from $input_file");
+
+ # No bind_params needed.
+ my $recstr = join(',', @records);
+ $query = sprintf($query, "WHERE sh2.record IN ($recstr)");
+
} else {
pod2usage(0);
}