in reply to Re: perl and psql
in thread perl and psql
$dbh->do ("INSERT INTO $table (start, end) VALUES (cluster[0], cluster[1]);");
In general, it's a good idea to use placeholders (like the OP already did in the SELECT statement), because that way you avoid potential quoting issues, and don't run the risk of SQL injections...
foreach my $cluster (@clusters) { my $sth = $dbh->prepare("INSERT INTO $table (start, end) VALUES (? +, ?)") or die $dbh->errstr; $sth->execute($cluster->[0], $cluster->[1]) or die $sth->errstr;; }
(assuming the interpolated variable $table is "safe", i.e. initialised from a static name stored program-internally...)
|
|---|