我正在尝试在 pSQL 表中插入一行,同时将键和值指定为占位符:
my @keys = keys %db_entr;
my @vals = values %db_entr;
my @items = (@keys, @values);
my $dbh = DBI->connect("DBI:Pg:dbname=testdb;host=localhost", "username", 'password', {'RaiseError' => 1});
my $sth = $dbh->prepare("INSERT INTO grid ( ?, ?, ? ) values ( ?, ?, ? )");
my $rows = $sth->execute(@items);
print "$rows effected\n";
但是,无论我做什么,这都会给我一个错误:
DBD::Pg::st execute failed: ERROR: syntax error at or near "$1"
LINE 1: INSERT INTO grid ( $1, $2, ...
^ at ./file.pl line 262, <STDIN> line 11.
有谁知道我可能做错了什么?