Hi forum!!!
I am assigning a variable dynamically and using it in a query to
fetch values from my database. Here is the pseudo code...
###########
my $string ;
my $q1 = "select * from bugs where target_milestone = ? and date
between ? and ?;
my $q2 = "select * from bugs where $string and target_milestone = ?
and date between ? and ?;
foreach my $q ($q1,$q2){
$stmt = $dbh->prepare($q1) or die ""; #####$dbh already has a valid
handle
$stmt->execute() or die "";
$string = "bug_id not in (1,2,3)"; #### 1,2,3 are eg. values which
i get after process $q1 and i #use it in $q2
}
##################################
howver it happens that $string is not used in $q2 i.e. $q2 is executed
without taking into account the newly assigned value to $string and
instead using '';
Is it that perl compiles the statement statement beforehand and never
really substitutes it when foreach loop advances to use $q2.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/