koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/acqui.simple marcimport.pl,1.6.2.4,1.6.2.5


From: Alan Millar
Subject: [Koha-cvs] CVS: koha/acqui.simple marcimport.pl,1.6.2.4,1.6.2.5
Date: Thu, 30 May 2002 22:33:36 -0700

Update of /cvsroot/koha/koha/acqui.simple
In directory usw-pr-cvs1:/tmp/cvs-serv19015

Modified Files:
      Tag: rel-1-2
        marcimport.pl 
Log Message:
Error handling in biblio/biblioitem addition


Index: marcimport.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui.simple/marcimport.pl,v
retrieving revision 1.6.2.4
retrieving revision 1.6.2.5
diff -C2 -r1.6.2.4 -r1.6.2.5
*** marcimport.pl       29 May 2002 14:39:05 -0000      1.6.2.4
--- marcimport.pl       31 May 2002 05:33:34 -0000      1.6.2.5
***************
*** 232,235 ****
--- 232,236 ----
  
  if ($input->param('insertnewrecord')) {
+     my $sth;
      my $isbn=$input->param('isbn');
      my $issn=$input->param('issn');
***************
*** 242,247 ****
      my $q_issn=$dbh->quote((($issn) || ('NIL')));
      my $q_lccn=$dbh->quote((($lccn) || ('NIL')));
!     my $sth=$dbh->prepare("insert into marcrecorddone values ($q_origisbn, 
$q_origissn, $q_origlccn, $q_origcontrolnumber)");
!     $sth->execute;
      my $sth=$dbh->prepare("select biblionumber,biblioitemnumber from 
biblioitems where issn=$q_issn or isbn=$q_isbn or lccn=$q_lccn");
      $sth->execute;
--- 243,249 ----
      my $q_issn=$dbh->quote((($issn) || ('NIL')));
      my $q_lccn=$dbh->quote((($lccn) || ('NIL')));
! 
!     #my $sth=$dbh->prepare("insert into marcrecorddone values ($q_origisbn, 
$q_origissn, $q_origlccn, $q_origcontrolnumber)");
!     #$sth->execute;
      my $sth=$dbh->prepare("select biblionumber,biblioitemnumber from 
biblioitems where issn=$q_issn or isbn=$q_isbn or lccn=$q_lccn");
      $sth->execute;
***************
*** 317,330 ****
        );
    
!   
! 
!       my $title=$input->param('title');
!       print << "EOF";
!       <table cellpadding=10 cellspacing=0 border=0 width=50%>
!       <tr><th bgcolor=black><font color=white>Record entered into 
database</font></th></tr>
!       <tr><td bgcolor=#dddddd>$title has been entered into the database with 
biblionumber
!       $biblionumber and biblioitemnumber $biblioitemnumber</td></tr>
!       </table>
  EOF
      } # if new record
  
--- 319,335 ----
        );
    
!       if ( $error ) {
!           print "<H2>Error adding biblio item</H2> $error\n";
!       } else { 
! 
!         my $title=$input->param('title');
!         print << "EOF";
!           <table cellpadding=10 cellspacing=0 border=0 width=50%>
!           <tr><th bgcolor=black><font color=white>Record entered into 
database</font></th></tr>
!           <tr><td bgcolor=#dddddd>$title has been entered into the database 
with biblionumber
!           $biblionumber and biblioitemnumber $biblioitemnumber</td></tr>
!         </table>
  EOF
+       } # if error
      } # if new record
  
***************
*** 399,470 ****
  
        # Make sure master biblio entry exists
!       $biblionumber=GetOrAddBiblio($dbh, $biblio);
  
!       # Get next biblioitemnumber
!       $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
!       $sth->execute;
!       ($biblioitemnumber) = $sth->fetchrow;
!       $biblioitemnumber++;
! 
!       print "<PRE>Next biblio item is $biblioitemnumber</PRE>\n" if $debug;
! 
!       $sth=$dbh->prepare("insert into biblioitems (
!         biblioitemnumber,
!         biblionumber,
!         volume,
!         number,
!         itemtype,
!         isbn,
!         issn,
!         dewey,
!         subclass,
!         publicationyear,
!         publishercode,
!         volumedate,
!         volumeddesc,
!         illus,
!         pages,
!         notes,
!         size,
!         place,
!         lccn,
!         marc)
!       values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" );
  
!       $sth->execute(
!         $biblioitemnumber,
!         $biblionumber,
!         $biblioitem->{volume},
!         $biblioitem->{number},
!         $biblioitem->{itemtype},
!         $biblioitem->{isbn},
!         $biblioitem->{issn},
!         $biblioitem->{dewey},
!         $biblioitem->{subclass},
!         $biblioitem->{publicationyear},
!         $biblioitem->{publishercode},
!         $biblioitem->{volumedate},
!         $biblioitem->{volumeddesc},
!         $biblioitem->{illus},
!         $biblioitem->{pages},
!         $biblioitem->{notes},
!         $biblioitem->{size},
!         $biblioitem->{place},
!         $biblioitem->{lccn},
!         $biblioitem->{marc} );
  
!       $sth=$dbh->prepare("insert into bibliosubject 
                (biblionumber,subject)
                values (?, ? )" );
!       foreach $subjectheading (@{$subjects} ) {
!           $sth->execute($biblionumber, $subjectheading);
!       }
  
!       $sth=$dbh->prepare("insert into additionalauthors 
                (biblionumber,author)
                values (?, ? )");
!       foreach $additionalauthor (@{$addlauthors} ) {
!           $sth->execute($biblionumber, $additionalauthor);
!       }
  
        return ( $biblionumber, $biblioitemnumber, $error);
--- 404,486 ----
  
        # Make sure master biblio entry exists
!       ($biblionumber,$error)=GetOrAddBiblio($dbh, $biblio);
  
!         if ( ! $error ) { 
!         # Get next biblioitemnumber
!         $sth=$dbh->prepare("select max(biblioitemnumber) from biblioitems");
!         $sth->execute;
!         ($biblioitemnumber) = $sth->fetchrow;
!         $biblioitemnumber++;
  
!         print "<PRE>Next biblio item is $biblioitemnumber</PRE>\n" if $debug;
!   
!         $sth=$dbh->prepare("insert into biblioitems (
!           biblioitemnumber,
!           biblionumber,
!           volume,
!           number,
!           itemtype,
!           isbn,
!           issn,
!           dewey,
!           subclass,
!           publicationyear,
!           publishercode,
!           volumedate,
!           volumeddesc,
!           illus,
!           pages,
!           notes,
!           size,
!           place,
!           lccn,
!           marc)
!         values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" );
! 
!         $sth->execute(
!           $biblioitemnumber,
!           $biblionumber,
!           $biblioitem->{volume},
!           $biblioitem->{number},
!           $biblioitem->{itemtype},
!           $biblioitem->{isbn},
!           $biblioitem->{issn},
!           $biblioitem->{dewey},
!           $biblioitem->{subclass},
!           $biblioitem->{publicationyear},
!           $biblioitem->{publishercode},
!           $biblioitem->{volumedate},
!           $biblioitem->{volumeddesc},
!           $biblioitem->{illus},
!           $biblioitem->{pages},
!           $biblioitem->{notes},
!           $biblioitem->{size},
!           $biblioitem->{place},
!           $biblioitem->{lccn},
!           $biblioitem->{marc} ) or  $error.=$sth->errstr ;
  
!         $sth=$dbh->prepare("insert into bibliosubject 
                (biblionumber,subject)
                values (?, ? )" );
!         foreach $subjectheading (@{$subjects} ) {
!             $sth->execute($biblionumber, $subjectheading) 
!                       or $error.=$sth->errstr ;
!       
!         } # foreach subject
  
!         $sth=$dbh->prepare("insert into additionalauthors 
                (biblionumber,author)
                values (?, ? )");
!         foreach $additionalauthor (@{$addlauthors} ) {
!           $sth->execute($biblionumber, $additionalauthor) 
!                       or $error.=$sth->errstr ;
!         } # foreach author
! 
!       } else {
!         # couldn't get biblio
!         $biblionumber='';
!         $biblioitemnumber='';
! 
!       } # if no biblio error
  
        return ( $biblionumber, $biblioitemnumber, $error);
***************
*** 487,490 ****
--- 503,507 ----
        my $debug=1;
        my $sth;
+       my $error;
        
        #-----
***************
*** 503,509 ****
            # Doesn't exist.  Add new one.
            print "<PRE>Adding biblio</PRE>\n" if $debug;
!           $biblionumber=&newbiblio($biblio);
!           print "<PRE>Added with biblio number $biblionumber</PRE>\n" if 
$debug;
!           &newsubtitle($biblionumber,$biblio->{subtitle} );
        }
  
--- 520,532 ----
            # Doesn't exist.  Add new one.
            print "<PRE>Adding biblio</PRE>\n" if $debug;
!           ($biblionumber,$error)=&newbiblio($biblio);
!           if ( $biblionumber ) {
!             print "<PRE>Added with biblio number=$biblionumber</PRE>\n" if 
$debug;
!             if ( $biblio->{subtitle} ) {
!               &newsubtitle($biblionumber,$biblio->{subtitle} );
!             } # if subtitle
!           } else {
!               print "<PRE>Couldn't add biblio: $error</PRE>\n" if $debug;
!           } # if added
        }
  
***************
*** 540,544 ****
            } else {
  
!               print "<font color=green>Item added with barcode $barcode
                        </font><P>\n";
              } # if error
--- 563,567 ----
            } else {
  
!               print "<font color=green size=+1>Item added with barcode 
$barcode
                        </font><P>\n";
              } # if error
***************
*** 549,552 ****
--- 572,576 ----
  my $menu = $input->param('menu');
  if ($file) {
+     my $sth;
      print "<a href=$ENV{'SCRIPT_NAME'}>Main Menu</a><hr>\n";
      my $qisbn=$input->param('isbn');
***************
*** 1022,1031 ****
                        my $q_lccn=$dbh->quote((($lccn) || ('NIL')));
                        my $q_controlnumber=$dbh->quote((($controlnumber) || 
('NIL')));
!                       my $sth=$dbh->prepare("select * from marcrecorddone 
where isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn or 
controlnumber=$q_controlnumber");
!                       $sth->execute;
!                       my $donetext='';
!                       if ($sth->rows) {
!                           $donetext="DONE";
!                       }
                        $sth=$dbh->prepare("select * from biblioitems where 
isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn");
                        $sth->execute;
--- 1046,1055 ----
                        my $q_lccn=$dbh->quote((($lccn) || ('NIL')));
                        my $q_controlnumber=$dbh->quote((($controlnumber) || 
('NIL')));
!                       #my $sth=$dbh->prepare("select * from marcrecorddone 
where isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn or 
controlnumber=$q_controlnumber");
!                       #$sth->execute;
!                       #my $donetext='';
!                       #if ($sth->rows) {
!                       #    $donetext="DONE";
!                       #}
                        $sth=$dbh->prepare("select * from biblioitems where 
isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn");
                        $sth->execute;
***************
*** 1110,1119 ****
                my $q_lccn=$dbh->quote((($lccn) || ('NIL')));
                my $q_controlnumber=$dbh->quote((($controlnumber) || ('NIL')));
!               my $sth=$dbh->prepare("select * from marcrecorddone where 
isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn or 
controlnumber=$q_controlnumber");
!               $sth->execute;
!               my $donetext='';
!               if ($sth->rows) {
!                   $donetext="DONE";
!               }
                $sth=$dbh->prepare("select * from biblioitems where 
isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn");
                $sth->execute;
--- 1134,1143 ----
                my $q_lccn=$dbh->quote((($lccn) || ('NIL')));
                my $q_controlnumber=$dbh->quote((($controlnumber) || ('NIL')));
!               #my $sth=$dbh->prepare("select * from marcrecorddone where 
isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn or 
controlnumber=$q_controlnumber");
!               #$sth->execute;
!               #my $donetext='';
!               #if ($sth->rows) {
!               #    $donetext="DONE";
!               #}
                $sth=$dbh->prepare("select * from biblioitems where 
isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn");
                $sth->execute;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]