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

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 [at] bugs = <F1>;
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( [at] bugs)
{
chomp($id);
$sth->execute($id);
while(my [at] row = $sth->fetchrow_array()){
open FILE, "filepath";
[at] arr=<FILE>;
splice( [at] arr,2,1);
open FILE, ">filepath";
print FILE [at] arr;
chop( [at] arr);
print FILE " [at] 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 [at] m .gmane.org
Gisbert.Selke [ Do, 02 Februar 2006 13:11 ] [ ID #1169932 ]
Datenbanken » gmane.comp.db.mysql.perl » AW: <<Spam-Verdacht>>query inside a loop

Vorheriges Thema: chopblanks error in 3.0002_5
Nächstes Thema: Extract files from a mysql database