From a93e5b61896b3e94c9ed43554645fbaf4135f0cb Mon Sep 17 00:00:00 2001 From: amillar Date: Sun, 9 Jun 2002 05:28:25 +0000 Subject: [PATCH] Sync biblioitems fields between acqui, acqui.simple, and updatedatabase --- C4/Acquisitions.pm | 94 +++++++++++++++++++++----------------- acqui.simple/marcimport.pl | 53 +-------------------- updater/updatedatabase | 4 +- 3 files changed, 56 insertions(+), 95 deletions(-) diff --git a/C4/Acquisitions.pm b/C4/Acquisitions.pm index 9dbec4b399..228c7a670f 100644 --- a/C4/Acquisitions.pm +++ b/C4/Acquisitions.pm @@ -591,64 +591,72 @@ sub modnote { sub newbiblioitem { my ($biblioitem) = @_; my $dbh = C4Connect; - my $query = "Select max(biblioitemnumber) from biblioitems"; - my $sth = $dbh->prepare($query); my $data; my $bibitemnum; + my $error; - $biblioitem->{'volume'} = $dbh->quote($biblioitem->{'volume'}); - $biblioitem->{'number'} = $dbh->quote($biblioitem->{'number'}); - $biblioitem->{'classification'} = $dbh->quote($biblioitem->{'classification'}); - $biblioitem->{'itemtype'} = $dbh->quote($biblioitem->{'itemtype'}); - $biblioitem->{'url'} = $dbh->quote($biblioitem->{'url'}); - $biblioitem->{'isbn'} = $dbh->quote($biblioitem->{'isbn'}); - $biblioitem->{'issn'} = $dbh->quote($biblioitem->{'issn'}); - $biblioitem->{'dewey'} = $dbh->quote($biblioitem->{'dewey'}); - $biblioitem->{'subclass'} = $dbh->quote($biblioitem->{'subclass'}); - $biblioitem->{'publicationyear'} = $dbh->quote($biblioitem->{'publicationyear'}); - $biblioitem->{'publishercode'} = $dbh->quote($biblioitem->{'publishercode'}); - $biblioitem->{'volumedate'} = $dbh->quote($biblioitem->{'volumedate'}); - $biblioitem->{'volumeddesc'} = $dbh->quote($biblioitem->{'volumeddesc'}); $biblioitem->{'illus'} = $dbh->quote($biblioitem->{'illus'}); - $biblioitem->{'pages'} = $dbh->quote($biblioitem->{'pages'}); - $biblioitem->{'notes'} = $dbh->quote($biblioitem->{'notes'}); - $biblioitem->{'size'} = $dbh->quote($biblioitem->{'size'}); - $biblioitem->{'place'} = $dbh->quote($biblioitem->{'place'}); - + # Get next unused number + my $query = "Select max(biblioitemnumber) from biblioitems"; + my $sth = $dbh->prepare($query); $sth->execute; $data = $sth->fetchrow_arrayref; $bibitemnum = $$data[0] + 1; - $sth->finish; $query = "insert into biblioitems set -biblioitemnumber = $bibitemnum, -biblionumber = $biblioitem->{'biblionumber'}, -volume = $biblioitem->{'volume'}, -number = $biblioitem->{'number'}, -classification = $biblioitem->{'classification'}, -itemtype = $biblioitem->{'itemtype'}, -url = $biblioitem->{'url'}, -isbn = $biblioitem->{'isbn'}, -issn = $biblioitem->{'issn'}, -dewey = $biblioitem->{'dewey'}, -subclass = $biblioitem->{'subclass'}, -publicationyear = $biblioitem->{'publicationyear'}, -publishercode = $biblioitem->{'publishercode'}, -volumedate = $biblioitem->{'volumedate'}, -volumeddesc = $biblioitem->{'volumeddesc'}, -illus = $biblioitem->{'illus'}, -pages = $biblioitem->{'pages'}, -notes = $biblioitem->{'notes'}, -size = $biblioitem->{'size'}, -place = $biblioitem->{'place'}"; + biblioitemnumber = ?, + biblionumber = ?, + volume = ?, + number = ?, + classification = ?, + itemtype = ?, + url = ?, + isbn = ?, + issn = ?, + lccn = ?, + dewey = ?, + subclass = ?, + publicationyear = ?, + publishercode = ?, + volumedate = ?, + volumeddesc = ?, + illus = ?, + pages = ?, + notes = ?, + size = ?, + marc = ?, + place = ? "; $sth = $dbh->prepare($query); - $sth->execute; + $sth->execute( + $bibitemnum, + $biblioitem->{'biblionumber'}, + $biblioitem->{'volume'}, + $biblioitem->{'number'}, + $biblioitem->{'classification'}, + $biblioitem->{'itemtype'}, + $biblioitem->{'url'}, + $biblioitem->{'isbn'}, + $biblioitem->{'issn'}, + $biblioitem->{'lccn'}, + $biblioitem->{'dewey'}, + $biblioitem->{'subclass'}, + $biblioitem->{'publicationyear'}, + $biblioitem->{'publishercode'}, + $biblioitem->{'volumedate'}, + $biblioitem->{'volumeddesc'}, + $biblioitem->{'illus'}, + $biblioitem->{'pages'}, + $biblioitem->{'notes'}, + $biblioitem->{'size'}, + $biblioitem->{'marc'}, + $biblioitem->{'place'}, + ) or $error=$sth->errstr; $sth->finish; $dbh->disconnect; return($bibitemnum); -} +} # sub newbiblioitem sub newsubject { my ($bibnum)=@_; diff --git a/acqui.simple/marcimport.pl b/acqui.simple/marcimport.pl index 9171cba8d9..4590640d9b 100755 --- a/acqui.simple/marcimport.pl +++ b/acqui.simple/marcimport.pl @@ -1401,58 +1401,9 @@ sub newcompletebiblioitem { ($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 "
Next biblio item is $biblioitemnumber
\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 ; + $biblioitem->{biblionumber}=$biblionumber; + $biblioitemnumber=newbiblioitem($biblioitem); $sth=$dbh->prepare("insert into bibliosubject (biblionumber,subject) diff --git a/updater/updatedatabase b/updater/updatedatabase index 852b8bedb3..e339fb49f6 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -17,7 +17,7 @@ use DBI; # Koha modules use C4::Database; -my $debug=1; +my $debug=0; my ( $sth, @@ -67,8 +67,10 @@ my %requirefields=( biblio=>{ 'abstract' => 'text' }, deletedbiblio=>{ 'abstract' => 'text' }, biblioitems=>{ 'lccn' => 'char(25)', + 'url' => 'varchar(255)', 'marc' => 'text' }, deletedbiblioitems=>{ 'lccn' => 'char(25)', + 'url' => 'varchar(255)', 'marc' => 'text' }, branchtransfers=>{ 'datearrived' => 'datetime' }, ); -- 2.39.5