-warn "query ".$query if $DEBUG;
-
- foreach my $servid (@id) {
- my $sth = $dbh->prepare("SELECT * FROM z3950servers WHERE id=? ORDER BY rank, name");
- $sth->execute($servid);
- while ( $server = $sth->fetchrow_hashref ) {
- warn "serverinfo ".join(':',%$server) if $DEBUG;
- my $option1 = new ZOOM::Options();
- $option1->option('async' => 1);
- $option1->option('elementSetName', 'F');
- $option1->option('databaseName', $server->{db});
- $option1->option('user', $server->{userid} ) if $server->{userid};
- $option1->option('password', $server->{password}) if $server->{password};
- $option1->option('preferredRecordSyntax', $server->{syntax});
- $option1->option( 'timeout', $server->{timeout} ) if ($server->{timeout});
- $oConnection[$s] = create ZOOM::Connection($option1)
- || $DEBUG
- && warn( "" . $oConnection[$s]->errmsg() );
- warn( "server data", $server->{name}, $server->{port} ) if $DEBUG;
- $oConnection[$s]->connect( $server->{host}, $server->{port} )
- || $DEBUG
- && warn( "" . $oConnection[$s]->errmsg() );
- $serverhost[$s] = $server->{host};
- $servername[$s] = $server->{name};
- $encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426");
- $s++;
- } ## while fetch
- } # foreach
- my $nremaining = $s;
- my $firstresult = 1;
-
- for ( my $z = 0 ; $z < $s ; $z++ ) {
- warn "doing the search" if $DEBUG;
- $oResult[$z] = $oConnection[$z]->search_pqf($query)
- || $DEBUG
- && warn( "somthing went wrong: " . $oConnection[$s]->errmsg() );
-
- # $oResult[$z] = $oConnection[$z]->search_pqf($query);
- }
-
- AGAIN:
- my $k;
- my $event;
- while ( ( $k = ZOOM::event( \@oConnection ) ) != 0 ) {
- $event = $oConnection[ $k - 1 ]->last_event();
- warn( "connection ", $k - 1, ": event $event (",
- ZOOM::event_str($event), ")\n" )
- if $DEBUG;
- last if $event == ZOOM::Event::ZEND;
- }
-
- if ( $k != 0 ) {
- $k--;
- warn $serverhost[$k] if $DEBUG;
- my ( $error, $errmsg, $addinfo, $diagset ) =
- $oConnection[$k]->error_x();
- if ($error) {
- if ($error =~ m/^(10000|10007)$/ ) {
- push(@errconn, {'server' => $serverhost[$k], 'error' => $error});
- }
- $DEBUG and warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n";
- }
- else {
- my $numresults = $oResult[$k]->size();
- my $i;
- my $result = '';
- if ( $numresults > 0 ) {
- for ($i = 0; $i < (($numresults < 20) ? $numresults : 20); $i++) {
- my $rec = $oResult[$k]->record($i);
- if ($rec) {
- my $marcrecord;
- $marcdata = $rec->raw();