Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$allaccounts = $sql_dbh->exec( "select * from othertable where acc in +($placeholders)", @files );
#!/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 ); } my $cc=0; foreach (@$allaccounts) { $cc++; # print report my $found = qq|$_->{ name }$_->{ number }|; print "\n $cc - Reporting: $found\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Large table query code help!
by moritz (Cardinal) on Feb 02, 2012 at 20:03 UTC | |
by Anonymous Monk on Feb 02, 2012 at 20:09 UTC | |
|
Re: Large table query code help!
by Anonymous Monk on Feb 02, 2012 at 20:05 UTC | |
by Anonymous Monk on Feb 02, 2012 at 20:48 UTC |