in reply to Optimization/Efficiency Question

Psst… young man...
Yes, over here...
Come on boy, a little closer...
Closer…
Not that close! You blasted barnacle head! I mean… hi.
I don't think this is a Perl issue at all. Your just trying to get help with an Access 97 problem.
Well if that is the case this link may be useful to you.

Plankton: 1% Evil, 99% Hot Gas.

Replies are listed 'Best First'.
Re: Re: Optimization/Efficiency Question
by Grygonos (Chaplain) on Sep 12, 2003 at 16:39 UTC

    Possibly so, I can't decipher whether it's somethin I'm doing in my Perl code, or if it's something to do with Access. I was asking for help with the Perl portion, if in fact that is what was the matter. thanks for the link though.

    P.S. First person with the correct answer gets a booster seat for their birthday *cue evil music*
      I don't get why you prepare the SELECT statement inside the loop. There's nothing variable in it... So put the prepare phase upfront.

      Also, you don't need separate prepare/execute/finish statements for an UPDATE query. You can replace it with one single do() (the DBI method).

      Alternatively, again, prepare the handle for the UPDATE query outside the loop. The code could look a bit like this:
      Version 1:

      $query = q{SELECT Referrals.1, Referrals.2, Referrals.3, Referrals.4, Referrals.5, Referrals.6, Referrals.7, Referrals.8, Referrals.9, Referrals.10, Referrals.11, Referrals.12, Referrals.13, Referrals.14, States.1 FROM Referrals INNER JOIN States On (Referrals.10 = States.1) WHERE AuditID = ?}; my $sth = $dbh->prepare($query); foreach my $audit (keys(%$audits)) { $sth->execute($audit); my @assign = $sth->fetchrow_array; $sth->finish(); $dbh->do(q{INSERT INTO report_printing_table (1,2,3,4,5,6,7,8,9,10,11,12,13) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)}, undef, $audit, @assign); }
      or Version 2:
      $query = q{SELECT Referrals.1, Referrals.2, Referrals.3, Referrals.4, Referrals.5, Referrals.6, Referrals.7, Referrals.8, Referrals.9, Referrals.10, Referrals.11, Referrals.12, Referrals.13, Referrals.14, States.1 FROM Referrals INNER JOIN States On (Referrals.10 = States.1) WHERE AuditID = ?}; my $sth = $dbh->prepare($query); my $updh = $dbh->prepare(q{INSERT INTO report_printing_table (1,2,3,4,5,6,7,8,9,10,11,12,13) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)}); foreach my $audit (keys(%$audits)) { $sth->execute($audit); my @assign = $sth->fetchrow_array; $sth->finish(); $updh->execute($audit, @assign); }
      There's no need for a finish() call for an UPDATE query.

      Maybe, just maybe, this also fixes your problem.

      I am not sure if this is a typo or not but you may want to look at this bit of code ...
      foreach my $audit (keys(%$audits)) { $query = q{ ... ); my $sth = $dbh->prepare($query); sth->execute($audit); ...
      It looks like you are setting up to run $query but you execute $audit. Maybe that is what you intended, but maybe its a typo.


      Well this stinks. dws has just pointed out that $audit is the query's parameters and not a typo.

      Plankton: 1% Evil, 99% Hot Gas.