Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fetch all records from table dbi

Status
Not open for further replies.

keerthi2016

Programmer
Jul 20, 2015
14
0
0
IN
I am expecting to fetch all the below records from table through perl. Currently, i am getting a out of memory issue. Any other best alternative way to read all the records.
Query to fetch all records from the table.
select cpu_id, system, generation, vendor, item, week_first_moved, week_last_moved from us_item_tbl
Rows :5812750
Fetching all records through below code and getting out of memory:

sub sane {
my $self = shift;
my %lookup;
my $dbh = DBI->connect ('dbi:Oracle:usbmfs', 'US', 'states', {AutoCommit => 0, RaiseError => 1});
my $sth = $dbh->prepare (qq{ select cpu_id, system, generation, vendor, item, week_first_moved, week_last_moved from us_item_tbl});
$sth->execute();
my $rows = @{$dbh->selectall_arrayref('select upc_id, system, generation, vendor, item, week_first_moved, eek_last_moved from uk_item_tbl')};
foreach my $row (@$rows) {
my($cpu, sys, $gen, $vend, $item, $wad, $wlm) =@$rows;
my $ean = sprintf "%02s%05s%05s", $sys, $vend, $item;
$cpu = sprintf "%014s", $cpu;
$lookup{$nae}{$cpu} = [$wad, $wlm];
}

}


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top