1
我在用下面的代碼的問題:DBI綁定參數和方括號
$sql = <<"END_SQL";
SELECT DISTINCT Matching.[CI M], Matching2_1.[LAC M], Matching2_1.[CI M], Matching.[Band M], Matching2_1.[Band M], Matching.Site, Matching2_1.Site, Matching.[BSC/RNC], Matching.[CellName M], Matching.[BSC/RNC M], Matching2_1.[CellName M]
FROM Matching, [N 900 - 900], Matching AS Matching2_1
WHERE Matching.[Band M]= ? AND Matching2_1.[Band M]= ? ;
END_SQL
$sth = $dbh->prepare($sql);
$sth->execute(900, 900);
列名包含空間,數據庫是MS接入所以我用方括號在查詢中使用它們
問題是,Perl將方括號解釋爲綁定參數,並且需要11個參數。
以下是錯誤:
DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 11. (SQL-07002) at NEIGHBORS MAPPING.pl line 89.
我不熟悉ODBC,但也許你可以試試這個:http://search.cpan.org/~mjevans/DBD-ODBC-1.56/ODBC.pm#odbc_ignore_named_placeholders – oals