4 use Time::HiRes qw/time/;
12 my ($userid, $sourceid, $rec_id, $entry_file, $map_file) = (1, 2, 1, 'record_entry.sql','record_id_map.pl');
15 "sourceid" => \$sourceid,
16 "entry_file=s" => \$entry_file,
17 "tcn_map_file=s" => \$map_file,
18 "userid=i" => \$userid,
19 "first=i" => \$rec_id,
24 open RE, ">$entry_file" or die "Can't open $entry_file! $!\n";
27 SET CLIENT_ENCODING TO 'UNICODE';
28 COPY biblio.record_entry (id,editor,creator,source,tcn_value,marc,last_xact_id) FROM STDIN;
33 my $parser = XML::LibXML->new;
36 while ( $xml .= <STDIN> ) {
43 my $doc = $parser->parse_string($xml);;
44 $tcn = $doc->documentElement->findvalue( '/*/*[@tag="035"][1]' );
56 $tcn =~ s/^.*?(\w+)\s*$/$1/go;
59 warn "\nNo TCN found for rec # $rec_id\n";
65 if (exists($$tcn_map{$tcn})) {
66 warn "\n !! TCN $tcn already exists!\n";
72 $$tcn_map{$tcn} = $rec_id;
74 print RE join("\t", ($rec_id,$userid,$userid,$sourceid,$tcn,$xml,$xact_id))."\n";
81 print RE "SELECT setval('biblio.record_entry_id_seq'::TEXT, $rec_id);\n";
83 open MAP, ">$map_file" or die "Can't open $map_file! $!\n";
84 print MAP Data::Dumper->Dump([$tcn_map],['tcn_map']);