我有一个关于 perl DBI 的 bind_param 的问题。以下 SQL 有效:
my $sth = $dbh->prepare("SELECT id FROM table WHERE id = 'string'");
$sth->execute();
虽然以下没有:
my $sth = $dbh->prepare("SELECT id FROM table WHERE id = ?");
$sth->execute('string');
最后一个查询导致的错误是[ODBC SQL Server Driver][SQL Server]The data types nvarchar(max) and ntext are incompatible in the equal to operator. (SQL-42000)
.
看起来bind_param
,它被 调用execute
,将“字符串”转换为 ntext。我该如何解决这个问题?