On Wed, Sep 10, 2003 at 02:05:24PM -0500, Ed Summers wrote: > On Wed, Sep 10, 2003 at 01:57:31PM -0400, Joshua Ferraro wrote: > > 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; > > } > > > > The call to as_usmarc() will populate the record length for you. So you > shouldn't have to do it yourself when building a record on the fly. We're you > getting an error somewhere about the record length not being populated? > > Your code looks to be creating a bunch of fields each with one subfield in them. > This is not correct. Furthermore, it is unlikely that the order that the > subfields come back from MySQL is the order in which you will want to build your > field...but I may be wrong there (not knowing Koha). I'm sure the Koha folks > have some utility for dumping their database as MARC don't they? If not they > should :)
How should the field/subfields be set up? I'm not sure about the order, what order should they be in? As far as a MARC utility there isn't one that I know of, but I've emailed the developer who built Koha's MARC support just in case. Thanks, Joshua > > //Ed