Hi Mike and all,

> Thanks for this post, I've come up with something like this, I think.
> http://sites.google.com/site/tumtumtreeorg/library, the attached file.

Thanks. Your queries seem simpler, it looks as if you just send the
ISBNs.

> running your script
> I'm getting an error
> ZOOM error 10010 "invalid query" from diag set

Becuse it's customized for BNF, not for LOC.
If you remove the username and password parameters and change the record
syntax to "USMARC" it will work, at least it works from here, see the
modified version of the initial script below.

Best wishes,
Sébastien.

zmloc.pl
========
#!/usr/bin/perl -w
# Example ISBN: 0596000278

# GET-MARC-ISBN -- Get MARC records by ISBN from a Z39.50 server
use strict;
use Carp;
use ZOOM;
use MARC::Record;

exit if ($#ARGV < 0);

# We handle multiple ISBNs in the same query by assembling a
# (potentially very large) search string with Prefix Query Notation
# that ORs the ISBN-bearing attributes.
#
# For purposes of automation, we want to request batches of many MARC
# records.  I am not a Z39.50 weenie, though, and I don't know
# offhand if there is a limit on how big a PQN query can be...

my $zq = "\...@attr 1=7 ". pop();
while (@ARGV) { $zq = '@or @attr 1=7 '. pop() ." $zq" }

## HERE IS THE CODE FOR Z3950 REC RETRIEVAL
# Set up connection management structures, connect
# to the server, and submit the Z39.50 query.

my $conn = new ZOOM::Connection(
  'z3950.loc.gov',
  7090,
  databaseName => "Voyager",
  elementSetName => "f",
  preferredRecordSyntax => "USMARC" # UNIMARC
);
croak "Unable to connect to server" if !defined($conn);

my $rs = $conn->search_pqf($zq); # result set

my $numrec = $rs->size();
print STDERR "$numrec record(s) found\n";

for (my $i = 0; $i < $numrec; $i++) {
  # Extract MARC records from Z3950
  # result set, and load MARC::Record.
  my $zrec = $rs->record($i);
  my $mrec = MARC::Record->new_from_usmarc($zrec->raw());
  print $mrec->as_usmarc();
}

Reply via email to