Paul and folks, MARCgetbiblio is the sub in Biblio.pm that contains the SQL queries that are supposed to generate a MARC record. I use it thusly: my $MARCRecord = &MARCgetbiblio($dbh,$bibid); my $recordstring=$MARCRecord->as_usmarc(); When I use as_usmarc() and I dump the record into a file and test the file for MARC compatibility with dumpmarc.pl (Paul, did you write this script?) I get the following:
koha:~# ./dumpmarc.pl -file datatest Invalid record length "02506" in record 1Invalid record length in record 1: Leader says 02506 bytes, but it's actually 2392 Invalid record terminator in record 1 No directory found in record 1 LDR 02506 00517 00100koha:~# I suspect that the sub MARCgetBiblio is somehow overriding the default behavior of as_usmarc() and creating a problem with the directory and leader generation: but that's just a guess. Here is MARCgetbiblio (I am suspicious of line 6; is it necessary?); sub MARCgetbiblio { # Returns MARC::Record of the biblio passed in parameter. my ($dbh,$bibid)[EMAIL PROTECTED]; my $record = MARC::Record->new(); #---- TODO : the leader is missing $record->leader(' '); my $sth=$dbh->prepare("select bibid,subfieldid,tag,tagorder,tag_indicator,su bfieldcode,subfieldorder,subfieldvalue,valuebloblink from marc_subfield_table where bibid=? order by tag,tagorder,subfieldcod e "); my $sth2=$dbh->prepare("select subfieldvalue from marc_blob_subfield whe re blobidlink=?"); $sth->execute($bibid); my $prevtagorder=1; my $prevtag='XXX'; my $previndicator; my $field; # for >=10 tags my $prevvalue; # for <10 tags while (my $row=$sth->fetchrow_hashref) { if ($row->{'valuebloblink'}) { #---- search blob if there is one $sth2->execute($row->{'valuebloblink'}); my $row2=$sth2->fetchrow_hashref; $sth2->finish; $row->{'subfieldvalue'}=$row2->{'subfieldvalue'}; } if ($row->{tagorder} ne $prevtagorder || $row->{tag} ne $prevtag ) { $previndicator.=" "; if ($prevtag <10) { $record->add_fields((sprintf "%03s",$prevtag),$prevvalue ) unless $prevtag eq "XXX"; # ignore the 1st loop } else { $record->add_fields($field) unless $prevtag eq " XXX"; } undef $field; $prevtagorder=$row->{tagorder}; $prevtag = $row->{tag}; $previndicator=$row->{tag_indicator}; if ($row->{tag}<10) { $prevvalue = $row->{subfieldvalue}; } else { $field = MARC::Field->new((sprintf "%03s",$prevt ag), substr($row->{tag_indicator}.' ',0,1), substr($row->{tag_indicator}.' ',1 ,1), $row->{'subfieldcode'}, $row->{'subfieldvalue'} ); } } else { if ($row->{tag} <10) { $record->add_fields((sprintf "%03s",$row->{tag}) , $row->{'subfieldvalue'}); } else { $field->add_subfields($row->{'subfieldcode'}, $r ow->{'subfieldvalue'} ); } $prevtag= $row->{tag}; $previndicator=$row->{tag_indicator}; } } # the last has not been included inside the loop... do it now ! if ($prevtag <10) { $record->add_fields($prevtag,$prevvalue); } else { # my $field = MARC::Field->new( $prevtag, "", "", %subfieldlist); $record->add_fields($field); } return $record; } Joshua On Fri, Sep 19, 2003 at 09:42:19AM -0500, Ed Summers wrote: > On Fri, Sep 19, 2003 at 07:58:01PM +0530, Saiful Amin wrote: > > I never had to worry about the record_length (pos 00-04) or the > > base_address (pos 12-16) in the leader. I think they are automagically > > updated while writing the record via $rec->as_usmarc(). > > saiful++ > > Yes, they should be automatically calculated when writing the file as marc. > > print $record->as_usmarc(); > > Albeit, this method should really be as_marc() or as_marc21() but there you go > :) > > //Ed