Hi Monks,

The code I have here works just fine bringing back the results I am looking for, but the problem is the amount of time that it is taking to process the query. If I put a exit just before the while loop it goes very fast how it should. The problem is when the code is been processing inside the while. Can anyone see some mistakes or some way to better improve this code, or the problem has nothing to do with the code but with the database itself. Another interesting thing is, sometimes the code will go fast maybe because of DB caching the data, but if I live it alone for about 20 minutes it will take forever again. I just would like to see if anyone could spot a problem on the code before I go after the database people. Is there anything perl wise that could be done to improve the speed of the fetching.

Thanks for the help!


#! c:\perl\bin\perl.exe -W use DBI; use strict; use CGI qw(:standard); use CGI::Carp; my $to_all_account; my @array_account; print header(); my $sql = " SELECT MASTERTABLE.ACCOUNT# FROM TEST.MASTERTABLE WHERE (MASTERTABLE.NUMBER LIKE '%1324940%') AND (MASTERTABLE.SERIAL = +'FF' OR MASTERTABLE.SERIAL = 'CC' OR MASTERTABLE.SERIAL = 'OO' OR MAS +TERTABLE.SERIAL = 'NN') "; #Connetcting to an AS400 Database using ODBC, is it secure? my $user = "MYUSER"; my $pass = "MYPASS"; my $dbh = DBI->connect("DBI:ODBC:MYDB",$user, $pass) || print "Connect + to MYDB fail: $!"; my $sth = $dbh->prepare($sql); $sth->execute() || die $sth->errstr; while ( $to_all_account = $sth->fetchrow_arrayref) { print "<br><font color=red><b>^^^^^^^^@{$to_all_account}^^^^^</b>< +/font><br>\n"; push (@array_account,@{$to_all_account}); } print "<br><font color=green><b>**@array_claim**</b></font><br>\n" +; }

In reply to DB Question, speed is the answer! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.