I need to do repeated insertions over many tables:
This is proving very slow, partly, I suspect, because of the new prepare for every insert. If I could use placeholders for both $table_name and $theValue, I could probably save a lot of time. Is there some way to do this, or can placeholders ony be used for the values?for $t (0 .. 1000) { $table_name = $tables[$t]; $theValue = $values[$t]; $sql = "INSERT INTO r".$table_name." VALUES ($theValue)"; $std = $dbh->prepare($sql) or die("Could not prepare! At table = +$table_name because " . $dbh->errstr); $std->execute() or die("Could not execute!" . $dbh->errstr); }
If I'm bothering the monastery with this, it's because I've already tried thihngs along the lines of
with dismal results.$sql = "INSERT INTO ? VALUES (?)"; $std = $dbh->prepare($sql) or die("Could not prepare! At table = $tabl +e_name because " . $dbh->errstr); for $t (0 .. 1000) { $table_name = r.$tables[$t]; $theValue = $values[$t]; $std->execute($table_name , $theValue) or die("Could not execute!" . $ +dbh->errstr); }
Thanks.
In reply to DBI: Use placeholders for table name? by punch_card_don
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |