Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Large table query code help!

by Anonymous Monk
on Feb 02, 2012 at 20:48 UTC ( #951530=note: print w/ replies, xml ) Need Help??


in reply to Re: Large table query code help!
in thread Large table query code help!

I see your point and as far as this code sample is, the issue here is that this line:
for( my $i = 0; $i < @data; $i += 50 ) { ...
should end after the last foreach loop, no db calls or whatever else should matter since you mentioned that all has been working, or:

#!/usr/bin/perl -w use strict; use CGI qw/:standard/; use POSIX qw(strftime); my $db = "test"; my $sql_dbh = lib::Db->connect( 'local' ); # get a list of account numbers my @data = map { $_->{ ACCOUNT } } @{ $sql_dbh->exec( qq|select accoun +t from my_table where type='A'|) }; if (!@data) { die "bye now";exit; } my $numb = @data; print "\n Numbers of Accounts: $numb\n"; # Check 50 records at time my $allaccounts; for( my $i = 0; $i < @data; $i += 50 ) { my @files = @data[$i .. $i+49]; #my $all = join(', ', @files); #print "\n $i - $all\n"; #test data #push(@files, "11223","5776","0001","87100"); my $placeholders = join ',', ('?') x @files; $allaccounts = $sql_dbh->exec( "select * from othertable where acc i +n ($placeholders)", @files ); #} # not here my $cc=0; foreach (@$allaccounts) { $cc++; # print report my $found = qq|$_->{ name }$_->{ number }|; print "\n $cc - Reporting: $found\n"; } } # end here

Enjoy it !!!


Comment on Re^2: Large table query code help!
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951530]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2014-08-21 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (143 votes), past polls