Reputation: 11
I'm having problems with the following code:
$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);
The columns name contains space, the database is MS access so I use square brackets to use them in a query
The problem is that Perl interprets the square brackets as a binding parameters and expects 11 parameters.
Here is the error:
DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 11. (SQL-07002) at NEIGHBORS MAPPING.pl line 89.
Upvotes: 1
Views: 149
Reputation: 123484
The Access Database Engine can also recognize backquotes as table/field delimiters, so if the quare brackets are giving you trouble then try
SELECT DISTINCT Matching.`CI M`, ...
Upvotes: 0