AW: <<Spam-Verdacht>>query inside a loop

"Selke, Gisbert W." <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <[email protected]>
Hi, Sham --

What type of variable is bugs.bug_id? If  it is numeric, it should work (at
least after newline removal). If it is numeric, however, direct
interpolation gives you an unquoted string in your select statement, which
is illegal (or at least will give you unwanted results). Instead of trying
manual quoting, it would be a simpler and cleaner approach to do it like
this:

use DBI;
open F1, "filepath";
$"=",";
my @bugs = <F1>;
close(F1);
my $dbh = 
 
DBI->connect("DBI:mysql:database=Pbugs;host=appletest","username","password"
,
               {'RaiseError' => 1});
  my $sth = $dbh->prepare("select bug_id,short_desc,bug_status 
                          from bugs where
                          bug_id=?") or die "can't prepare statement";
foreach my $id(@bugs)
{
  chomp($id);
  $sth->execute($id);
  while(my @row = $sth->fetchrow_array()){
    open FILE, "filepath";
    @arr=<FILE>;
    splice(@arr,2,1);
    open FILE, ">filepath";
    print FILE @arr;
    chop(@arr);
    print FILE "@row\n";
    close(FILE); 
  }
}
$sth->finish();
$dbh->disconnect();

Hope this helps.

\Gisbert


-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.