in reply to dbi question
my $q1 = $dbh->prepare("sql statement"); my $q2 = $dbh->prepare("sql statement 2 with ?"); $q1->execute(); while($data = $q1->fetchrow_hashref()){ $q2->execute($data->{field}); while($more_data = $q2->fetrow_hashref()){ # code here } }
You can execute a prepared statement any number of times, each time passing in a number of values to "bind" to ? placeholders within the SQL. Some databases even support "named" placeholders ie:
my $sth = $dbh->prepare("select * from table where field = :nam"); $sth->bind_param(':nam', $value); $sth->execute();
See DBI and look for "Statement Handle Methods" for details.
A truely compassionate attitude towards other does not change, even if they behave negatively or hurt you
His Holiness, The Dalai Lama
|
|---|