MARC stuff : beginning to use MARC::Record package.
[koha.git] / C4 / test.pl
1 package C4::test;
2 use strict;
3 require Exporter;
4 use C4::Database;
5 use C4::Catalogue;
6
7 our $dbh=&C4Connect;
8 $dbh->do("delete from marc_subfield_table");
9 $dbh->do("delete from marc_blob_subfield");
10 &MARCaddSubfield(1,'001',1,'##','a',1,'1 - This is a value');
11 &MARCaddSubfield(1,'001',1,'##','b',1,'2 - This is another value');
12 &MARCaddSubfield(1,'001',1,'##','c',1,"3 - This is a value very very long. I try to make it longer than 255 char. I need to add something else. will it be long enough now... I'm not sure. That's why i continue to add a few word to this very important sentence. Now I hope it will be enough... Oh, not it need some more characters. So i add stupid strings : xxxxxxxxxxxxxxx dddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeee rrrrrrrrrrrrrrrrrrr ffffffffffffffffff");
13 &MARCaddSubfield(1,'001',1,'##','d',1,"4 - This is another value very very long. I try to make it longer than 255 char. I need to add something else. will it be long enough now... I'm not sure. That's why i continue to add a few word to this very important sentence. Now I hope it will be enough... Oh, not it need some more characters. So i add stupid strings : xxxxxxxxxxxxxxx dddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeee rrrrrrrrrrrrrrrrrrr ffffffffffffffffff");
14 print "change 1\n";
15 &MARCchangeSubfield(1,"1new - this is a changed value");
16 print "change 2\n";
17 &MARCchangeSubfield(2,"2new - go from short to long subfield... uuuuuuuuuuuuuuuuuuuuuuuu yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy tttttttttttttttttttttttttttttttt rrrrrrrrrrrrrrrrrrrrrr eeeeeeeeeeeeeeeeeeeeeeeee zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq ssssssssssssssssssssssssss ddddddddddddddddddddddddddddddd fffffffffffffffffffffffff ggggggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhhhhhhh jjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkk");
18 print "change 3\n";
19 &MARCchangeSubfield(3,"3new - go from long to short subfield...");
20 print "change 4\n";
21 &MARCchangeSubfield(4,"4new - stay with blob subfield...uuuuuuuuuuuuuuuuuuuuuuuu yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy tttttttttttttttttttttttttttttttt rrrrrrrrrrrrrrrrrrrrrr eeeeeeeeeeeeeeeeeeeeeeeee zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq ssssssssssssssssssssssssss ddddddddddddddddddddddddddddddd fffffffffffffffffffffffff ggggggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhhhhhhh jjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkk");
22 my $x= &MARCfindSubfield(1,'001','a','',1);
23 my $record= MARC::Record->new();
24 $record->leader("58973");
25 $record->add_fields('100',1,'',a => 'Logan, Robert K.', d => '1000-');
26 $record->add_fields('110',1,'',d => '1939-');
27
28 my $record2=MARCkoha2marc("123456","author","title","unititle","notes","abstract",
29         "serial","seriestitle","copyrightdate","biblioitemnumber","volume","number",
30         "classification","itemtype","isbn","issn",
31         "dewey","subclass","publicationyear","publishercode",
32         "volumedate","illus","pages","notes",
33         "size","place","lccn");
34 &MARCaddMarcBiblio($record2);
35 # parse all subfields 
36 my @fields = $record->fields();
37 foreach my $field (@fields) {
38     my @subf=$field->subfields;
39     for my $i (0..$#subf) {
40 #    print $field->tag(), " ", $field->indicator(1),$field->indicator(2), "subf: ", $subf[$i][0]," =",$subf[$i][1]," <-- \n";
41 }
42 }
43 #print $record->as_formatted();