Perl script to convert existing Koha tables to the new MARC tables.
[koha_gimpoz] / marc / koha2marc
1 #!/usr/bin/perl
2
3 # TODO
4 # add subtitle entry to marcimport (for stewelm)
5 # swap illustrator and additional authors for marcimport.pl
6 # fix replacement price entry (always coming up as zero)
7 # Check serial title when determining if biblio already exists
8
9
10 my $lc1='#dddddd';
11 my $lc2='#ddaaaa';
12
13
14 system("mysql Koha -ptestpass < deletemarc");
15
16 use C4::Database;
17 use C4::Catalogue;
18 use CGI;
19 use DBI;
20 #use strict;
21 use C4::Acquisitions;
22 use C4::Output;
23 my $dbh=C4Connect;
24 my $userid=$ENV{'REMOTE_USER'};
25
26
27 my $dbh=C4Connect;
28
29
30 my $sth=$dbh->prepare("select * from biblio,biblioitems where biblio.biblionumber=biblioitems.biblionumber");
31 $sth->execute;
32 my $env;
33
34 while (my $biblioitem=$sth->fetchrow_hashref) {
35     print "Processing $biblioitem->{'title'}\n";
36     my $Record_ID;
37     ($env, $Record_ID) = newBiblioItem($env,$biblioitem);
38     my $sti=$dbh->prepare("select * from items,biblioitems where items.biblioitemnumber=biblioitems.biblioitemnumber and biblioitems.biblioitemnumber=$biblioitem->{'biblioitemnumber'}");
39     $sti->execute;
40     while (my $item=$sti->fetchrow_hashref) {
41         newItem($env, $Record_ID, $item);
42     }
43 }