From: Mike Rylander Date: Wed, 19 Apr 2017 14:34:25 +0000 (-0400) Subject: Use a cursor to pull MARC data from the DB X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a17c5369a313a41a53982b2ae52aeaf77a89d6f6;p=working%2FEvergreen.git Use a cursor to pull MARC data from the DB Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/support-scripts/marc_export.in b/Open-ILS/src/support-scripts/marc_export.in index 5c0115cba1..b46b03ebe5 100755 --- a/Open-ILS/src/support-scripts/marc_export.in +++ b/Open-ILS/src/support-scripts/marc_export.in @@ -403,8 +403,7 @@ ACN_JOIN sub execute_query { my $self = shift; $self->build_query() unless ($self->{query}); - $self->{sth} = $self->{handle}->prepare($self->{query}); - return $self->{sth}->execute; + return $self->{handle}->do("declare csr cursor with hold for $$self{query}"); } sub next { @@ -435,7 +434,7 @@ sub next { return $self->next(); } } else { - my $data = $self->{sth}->fetchrow_hashref; + my $data = $self->{handle}->prepare('fetch 1 from csr')->execute->fetchrow_hashref; if ($data) { $r = $self->{breClass}->from_bare_hash($data); if ($Marque::config->option_value('format') eq 'BRE') { @@ -506,6 +505,8 @@ sub next { $self->{mfhds} = [$self->sres_for_bre($r)]; } } + } else { + $self->{handle}->do('close csr'); } } # Common stuff that doesn't depend on record type. @@ -742,14 +743,13 @@ sub build_query { sub execute_query { my $self = shift; $self->build_query() unless ($self->{query}); - $self->{sth} = $self->{handle}->prepare($self->{query}); - return $self->{sth}->execute; + return $self->{handle}->do("declare csr cursor with hold for $$self{query}"); } sub next { my $self = shift; my $output; - my $data = $self->{sth}->fetchrow_hashref; + my $data = $self->{handle}->prepare('fetch 1 from csr')->execute->fetchrow_hashref; if ($data) { my $format = $Marque::config->option_value('format'); @@ -830,6 +830,8 @@ sub next { } } } + } else { + $self->{handle}->do('close csr'); } return $output;