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

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

am 02.02.2006 13:11:10 von Gisbert.Selke

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 = ;
close(F1);
my $dbh =

DBI->connect("DBI:mysql:database=Pbugs;host=appletest","user name","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=;
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/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org