Hello everyone,
I am new to this list.  I'm also very new to Perl so please bear with me:-).
I am working on a Z3950 Server for my library (which is using Koha for ILS) and
I am having trouble generating MARC records using MARC::Record.  I am generatingthe 
records from a MySQL database and I don't know how to determine on-the-fly
what the leader length and base address are (also I'm not sure how to use the
set_leader_lengths "access method").

My code is below...any suggestions?

Thanks,

Joshua Ferraro
Nelsonville Public Library

Here is my code(this sub should build one record from Koha's marc_subfield_table
using one bibid stored in @bib_list):

sub fetch_handler {
        my ($args) = @_;
        # warn "in fetch_handler";      ## troubleshooting
        my $offset = $args->{OFFSET};
        $offset -= 1;                   ## because $args->{OFFSET} 1 = record #1
        chomp (my $bibid = $bib_list[$offset]);
        my $sql_query = "SELECT tag, subfieldcode, subfieldvalue FROM marc_subfi
eld_table where bibid=?";
        my $sth_get = $dbh->prepare("$sql_query");
        $sth_get->execute($bibid);

        ## create a MARC::Record object
        my $rec = MARC::Record->new();

        ## create the fields
        while (my @data=$sth_get->fetchrow_array) {

                my $tag = $data[0];
                my $subfieldcode = $data[1];
                my $subfieldvalue = $data[2];

                my $field = MARC::Field->new(
                                                  $tag,'','',
                                                  $subfieldcode => $subfieldvalu
e,
                                            );

                $rec->append_fields($field);

                ## build the marc string and put into $record
                my $record = $rec->as_usmarc();
                $args->{RECORD} = $record;
        }

Reply via email to