#!/m1/shared/bin/perl use DBI; $ENV{'ORACLE_HOME'}="/oracle/app/oracle/product/11.2.0.3/db_1"; $rssdate = `date`; chomp $rssdate; ### Require adjunct scripts to do character reencoding and date formats require "/m1/scripts/misc/MARCtoLatin.pl"; require "/m1/scripts/misc/date.pl"; ### Change to the working directory chdir("/m1/scripts/newbooks"); ### Query the Voyager database and get lists of new materials by call number. ### Then, parse the call number and associate it with disciplines as defined in ### %call_subs. Save the results to hashes. &GetNewItems; ### Print each item to the web content database and to an RSS XML file #&PrintRecords; close OUT; exit; ###################################################################### ###################################################################### sub GetNewItems { ### Voyager RO User login $dbuser = ""; $dbpassw = ""; ### Hash by call number to associate LC Classes with disciplines %call_subs = ( "PN" => "English, Film, Theater", "PQ" => "Foreign Languages and Literatures", "PR" => "English", ); ### Connect to database $dbh = DBI->connect('dbi:Oracle:', $dbuser, $dbpassw); ### Get statement handle for this SQL stmt ###SQL query removed for brevety's sake # -- # -- execute the query # -- $sth->execute(); $sth->bind_col( 1, \$bib_id ); $sth->bind_col( 2, \$_title_marc ); $sth->bind_col( 3, \$timedate ); $sth->bind_col( 4, \$callno ); $sth->bind_col( 5, \$mfhd_id ); $sth->bind_col( 6, \$trash ); $sth->bind_col( 7, \$location ); $sth->bind_col( 8, \$loca_id ); $sth->bind_col( 9, \$isbn ); open(OUT, ">out"); ### Process each record returned from the Voyager query. while($sth->fetch) { $location =~ s/'/''/gi; ### Build a persistent URL to the catalog record $lucyurl = qq{http://lucy2.skidmore.edu/vwebv/holdingsInfo?bibId=$bib_id}; ### Use date.pl to convert the timestamp into a readable date $date = $timedate; $display_date = &DisplayDate($date); ### Get the LC Class from the call number $call = substr($callno, 0, 3); $call =~ s/\d*//gi; #print "$call"; ### Convert the title to Latin1 and remove the trailing slash $title = &CharConv($_title_marc); $title =~ s/\/\s*$//gi; ### If there is more than one discipline associated with the LC Class, ### build an array of disciplines @subjects = split(/,/, $call_subs{$call}); #print "@subjects"; ### For each subject, get the record data and save it to a hash foreach $subject (@subjects) { if ($subject eq 'Dance'){ ($uptocutter,$therest) = split(/\./, $call); $uptocutter =~ s/\D//g; if ($uptocutter < 1580 || $uptocutter > 1799){ next; #print OUT qq{$uptocutter\n}; }else{ &saveRecords; } }else{ &saveRecords; } ### -- End of if ($subject) } ### -- End of foreach $subject } ### -- End of while... } ### -- End of &GetNewRecords sub saveRecords { $subject =~ s/^\s*//gi; #print "$subject"; #print OUT qq{$bib_id, $timedate, $title, $add_date, $subject\n\n}; ### Build an index variable and save each field to its own hash $id++; $title{$id} = $title; $timedate{$id} = $timedate; $display_date{$id} = $display_date; $subject{$id} = $subject; $callno{$id} = $callno; $urls{$id} = $lucyurl; $location{$id} = $location; $loca_id{$id} = $loca_id; $isbn{$id} = $isbn; } ### - End of sub saveRecords