Hi there Monks!
I just cant see it anymore, but I have to execute a query with account numbers in this array that will have at least 20000 values in it, well I need to check in three other tables if they match and get rid of them after reporting on them. My process of not letting all the 20000 into the "IN Operator" on the SQL query works well for me. But my question here is why I am loosing the value of this array (@acc_list) after the first "while"?
Any suggestions would be nice, here is a test code to express my frustration:
#!/usr/bin/perl -w
use strict;
use CGI qw/:standard/;
my @acc_list = (00001 .. 1000); # this will have at lest 20000 accout
+numbers in
if (!@acc_list) {
die " Nothing at this time";exit;
}
# From 1 table
my $c_1=0;
my $tb1;
while ( @acc_list ) {
$c_1++;
my @files1 = splice( @acc_list, 0, 100 );
print "\n23 - @files1\n";
#my $holders_one = join ',', ('?') x @files1;
#$tb1 = $dbh->exec_select( qq|select * from table1 where acc in ($ho
+lders_one)|,@files1 );
}
foreach (@$tb1) {
print "\n1- Found 1\n";
}
print "\n\n 33 - @acc_list \n\n";
# From 2 table
my $c_2=0;
my $tb2;
while ( @acc_list ) {
$c_2++;
my @files2 = splice( @acc_list, 0, 100 );
#my $holders_two = join ',', ('?') x @files2;
#$tb2 = $dbh->exec_select( qq|select * from table2 where acc in ($ho
+lders_two)|,@files2 );
}
foreach (@$tb2) {
print "\n 2- Found 2\n";
}
print "\n\n 52 - @acc_list \n\n";
# From 3 table
my $c_3=0;
my $tb3;
while ( @acc_list ) {
$c_3++;
my @files3 = splice( @acc_list, 0, 100 );
#my $holders_three = join ',', ('?') x @files3;
#$tb3 = $dbh->exec_select( qq|select * from table3 where acc in ($ho
+lders_three)|,@files3 );
}
foreach (@$tb3) {
print "\n 3- Found 3\n";
}
print "\n\n68 - **@acc_list** \n\n";
print "\n\n Done \n\n";
Thanks for looking!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.